欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

liWARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available 有大用 有大大用 有大大大用

当执行 pip 或 pip3 安装模块时 

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

我自己亲自做的方法 

/usr/local/bin/pip3.10 install argon2  -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com



pip is configured with locations that require TLS/SSL, however the ssl module in Python is notable


现象

执行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
                       

原因

没有通过该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/
   
           

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

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
           

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

vim ~/.pip/pip.conf

修改文件内容如下

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

[install]
trusted-host = mirrors.aliyun.com
            
  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. 检查环境,如windows配置环境变量

D:\Anaconda3 
D:\Anaconda3\Scripts
D:\Anaconda3\Library\bin

文章知识点与官方知识档案匹配,可进一步学习相关知识

网络技能树首页概览45042 人正在系统学习中                


               

来自  https://blog.csdn.net/z_johnny/article/details/137568407                


               

普通分类: