pip安装出现SSL问题三种解决方法

文章讲述了在中国由于网络限制无法访问pypi.org,以及如何通过修改pip配置、安装openssl或使用国内镜像解决Python包如torchsummary的安装问题。
摘要由CSDN通过智能技术生成

 Could not fetch URL https://pypi.org/simple/torchsummary/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/torchsummary/ (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 torchsummary (from versions: none)
ERROR: No matching distribution found for torchsummary

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

碰到这个问题,主要原因是网站pypi.python.org在国内是别墙了,在安装程序时,无法从python官网下载资料导致的。

下面解决方法适合windows系统

1.在C盘,进入%user%pip目录,就是在当前的用户找到pip文件夹,在里面创建pip.ini

文件,文件内容如下

[global] 
index-url=http://pypi.douban.com/simple/
[install] 
trusted-host=pypi.douban.com

 2.保存,重新使用pip install xx即可

方法2:安装最新的openssl

打开网址:[ Downloads ] - /source/index.html

下载安装包:https://www.openssl.org/source/openssl-1.1.1d.tar.gz

编译安装:

tar -zxvf openssl-1.1.1d.tar.gz
cd openssl-1.1.1d
 
./config --prefix=/usr/local/openssl/
make && make install && make clean
 
mv /usr/bin/openssl /usr/bin/openssl.bak
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

方法三:

首先运行下面的代码:

pip config set global.extra-index-url http://mirrors.aliyun.com/pypi/simple

2. 找到上面路径下的文件,使用以下内容覆盖原本pip.ini中的内容

[global]
index-url = https://mirrors.aliyun.com/pypi/simple
extra-index-url = https://mirrors.aliyun.com/pypi/simple
 
[install]
trusted-host = 
	mirrors.aliyun.com
	pypi.douban.com
	pypi.tuna.tsinghua.edu.cn
	pypi.mirrors.ustc.edu.cn
	mirrors.ustc.edu.cn
	mirrors.bfsu.edu.cn
	pypi.hustunique.com

 

  • 20
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值