当前位置:   article > 正文

pip is configured with locations that require TLS/SSL, however the ssl module in Python is notable_hint: it looks like a path. the path does exist.

hint: it looks like a path. the path does exist.

现象

执行pip install时报错:

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Hint: It looks like a path. The path does exist. 
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

  • 1
  • 2
  • 3
  • 4
  • 5

原因

没有通过该SSL安全协议的认证,通常是由于开启了网络代理、VPN 或者网络抓包等软件的导致的

解决办法

  1. 临时关闭代理、VPN 或者网络抓包等软件
    最推荐的办法是临时关闭代理、VPN 或者网络抓包等软件,但是如果关闭后下载速度过慢可以尝试后面两种解决办法

  2. 通过镜像的 HTTP 源来避免 SSL 认证问题【推荐】
    由于是 SSL 是 HTTPS 协议需要的,因此我们可以切换至 HTTP 的镜像站来进行安装下载

HTTPS 现在已经比较普及,有不少镜像源也早已经切换至 HTTPS 协议,但部分镜像源在支持 HTTPS 协议的而同时也还支持 HTTP 协议,下面简单罗列几个 pip 镜像源

# 清华,仅支持 HTTPS
https://pypi.tuna.tsinghua.edu.cn/simple/

# 阿里,HTTP 和 HTTPS 均支持
http://mirrors.aliyun.com/pypi/simple/
https://mirrors.aliyun.com/pypi/simple/

# 豆瓣,HTTP 和 HTTPS 均支持
http://pypi.doubanio.com/simple/
https://pypi.doubanio.com/simple/

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

安装时第三方包时可以参考如下命令:

pip install xxx-package -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install -r requirements.txt -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
  • 1
  • 2

如果想永久使用镜像站,则需要修改配置文件,以 Linux 为例:

vim ~/.pip/pip.conf
  • 1

修改文件内容如下

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host = mirrors.aliyun.com
  • 1
  • 2
  • 3
  • 4
  • 5
  1. 切换至低版本 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
python -m pip install pip==20.2.4 -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
  • 1
  • 2
  1. 检查环境,如windows配置环境变量
D:\Anaconda3 
D:\Anaconda3\Scripts
D:\Anaconda3\Library\bin 
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/712984
推荐阅读
相关标签
  

闽ICP备14008679号