python pip出现pip is configured with locations that require TLS/SSL异常处理方法

通过源码方式安装Python3.7之后pip功能异常,提示:

[root@localhost ~]# pip install httpbin
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting httpbin
  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/httpbin/
  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/httpbin/
  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/httpbin/
  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/httpbin/
  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/httpbin/
  Could not fetch URL https://pypi.org/simple/httpbin/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/httpbin/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
  Could not find a version that satisfies the requirement httpbin (from versions: )
No matching distribution found for httpbin
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
[root@localhost ~]#

查阅资料之后发现:在./configure过程中,如果没有加上–with-ssl参数时,默认安装的软件涉及到ssl的功能不可用,
刚好pip3过程需要ssl模块,而由于没有指定,所以该功能不可用。

首先安装openssl-devel

 yum -y install openssl-devel

然后重新编译安装,不过这一次除了指定安装位置之外请额外指定--with-ssl参数:

./configure --prefix=/usr/local/python3 --with-ssl

参考:
python pip 出现locations that require TLS/SSL异常处理方法 https://blog.csdn.net/zhengcaihua0/article/details/79681991

上一篇:4.爬虫 requests库讲解 GET请求 POST请求 响应


下一篇:Python接口自动化测试