pip安装包报错
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, 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/requests/
解决方法
修改非https源
# 阿里HTTP源
http://mirrors.aliyun.com/pypi/simple/
# 豆瓣HTTP源
http://pypi.doubanio.com/simple/
使用pip安装包的时单次修改可以使用
pip install xxx-package -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
#python3
pip3 install xxx-package -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
修改配置文件永久修改,Linux 为例
vim ~/.pip/pip.conf
内容如下
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com
切换低版本pip
经过测试,当 pip 版本高于 20.3 后才会出现此错误,因此我们可以手动将 pip 版本降级至 20.2.4 或者 20.3b1 等较低版本即可
python -m pip install pip==20.2.4 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
#python3
python3 -m pip install pip==20.2.4 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
参考:https://ywang-wnlo.github.io/posts/2e7aa01a/ 进行修改