新到手Mac上安装python环境,在pip install时出现以下错误:
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661) - skipping
网上流传的解决方案:
- openssl的版本问题:
brew update
brew uninstall openssl
brew install openssl
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
update openssl之后需要重新安装python
- 通过trusted-host:
pip install --trusted-host pypi.python.org pip --upgrade
- 更换pip mirror:
$ cat ~/.config/pip/pip.conf
[global]
proxy = http://my-proxy:8080
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com
- update pip:
pip install --upgrade pip
- 通过源码重装pip:
$ curl 'https://bootstrap.pypa.io/get-pip.py' > get-pip.py
$ sudo python get-pip.py
我尝试了几种方法,1结合5解决了问题,但是具体原因没有进一步研究。