centos7.9环境下,python3.8,pip install提示:WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available

[root@localhost local]# pip3 install  apscheduler==3.6.3
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting apscheduler==3.6.3
  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/apscheduler/
  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/apscheduler/
  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/apscheduler/
  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/apscheduler/
  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/apscheduler/
  Could not fetch URL https://pypi.org/simple/apscheduler/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/apscheduler/ (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 apscheduler==3.6.3 (from versions: none)
ERROR: No matching distribution found for apscheduler==3.6.3
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

windows下面python3.8未出现这样的问题,在linux环境下python3.6也未出现这样的问题,可能高版本对安全校验这块加强了,

解决办法:

1、编译的时候要在后面加--with-ssl,
./configure --prefix=/usr/local/python3 --with-ssl
2、:要在在pip.conf下加上trust-host
Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)

内容如下:

[global]
index-url=https://pypi.doubanio.com/simple/
[install]
trusted-host=pypi.doubanio.com
windows下,直接在user目录中创建一个pip目录,如:C:Usersxxpip,新建文件pip.ini。内容同上。

(注意:如果中央仓库地址地址不是https地址可能用不着第2步)

原文地址:https://www.cnblogs.com/feibazhf/p/14048261.html