当我尝试在MacOS Mojave上安装pip时,我遇到下一个错误
我试图使用
$ brew install python
但它不起作用
$ python --version
蟒蛇 3.7.4
$ sudo python get-pip.py
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting pip
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement pip (from versions: none)
ERROR: No matching distribution found for pip
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
如果 python 的 Homebrew 安装成功,则很可能已经安装了 pip。
The Hitchhiker's Guide to Python指出,当通过Homebrew安装Python时,"Homebrew[自动]为你安装指向Homebrew'd Python 3的pip。
尝试运行which pip
或which pip3
。如果您得到/usr/local/bin/pip
或/usr/local/bin/pip3
的响应,那么Homebrew已经为您安装了pip。否则请尝试brew unlink python3 && brew link python3
.
为了清楚起见,来自上述指南:
$ python
将启动Homebrew安装的Python 3解释器。
$ python2
将启动Homebrew安装的Python 2解释器(如果有的话(。
$ python3
将启动Homebrew安装的Python 3解释器。
据我所知,pip
、pip2
和pip3
也会这样做。