ubuntu pip is configured with locations that require TLS/SSL

ubuntu pip is configured with locations that require TLS/SSL

背景:
ubuntu 14.04

python3.8 
使用pip install pymsql 提示错误:

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting django
  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/django/
  WARNING: Retrying (Retry(total=3, 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/django/
  WARNING: Retrying (Retry(total=2, 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/django/
  WARNING: Retrying (Retry(total=1, 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/django/
  WARNING: Retrying (Retry(total=0, 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/django/
  Could not fetch URL https://pypi.org/simple/django/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/django/ (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 django (from versions: none)
ERROR: No matching distribution found for django
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

原因:

因为pip安装第三方库需要ssl模块,而python默认安装ssl功能是不可用的

第一种解决方法:

解决办法是重新编译python3安装文件,加上--with-ssl参数就可以让pip3使用ssl功能了

#重新编译安装
./configure  --enable-optimizations --with-ssl

Ubuntu 16.04 安装(install)python3.8

第二种解决方法:更换pip源

国内源

国内一些常用的软件源如下:

阿里云:http://mirrors.aliyun.com/pypi/simple/

中国科技大学:https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣:http://pypi.douban.com/simple/

清华大学:https://pypi.tuna.tsinghua.edu.cn/simple/

中国科学技术大学:http://pypi.mirrors.ustc.edu.cn/simple/

永久修改pip源

如果需要永久修改pip的软件镜像源,可以通过修改配置文件实现。

在Linux下,修改~/.pip/pip.conf,如果没有则创建:

mkdir ~/.pip
vim ~/.pip/pip.conf

添加以下内容

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

或者是:

[global]  
timeout = 6000  
index-url = http://pypi.douban.com/simple/  
[install]  
use-mirrors = true  
mirrors = http://pypi.douban.com/simple/  
trusted-host = pypi.douban.com

参考:pip安装使用国内镜像源

原文:http://www.chenxm.cc/article/1078.html

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值