CentOS7安装Python3之后使用pip命令(准确来说是使用镜像源的时候)出现问题:
(Py3_dev) [root@ onefine~]# pip install -i https://pypi.doubanio.com/simple httpbin
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Looking in indexes: https://pypi.doubanio.com/simple
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.doubanio.com/simple/httpbin/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.doubanio.com', 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
(Py3_dev) [root@ onefine ~]#
在./configure
过程中,如果没有加上–with-ssl
参数时,默认安装的软件涉及到ssl的功能不可用,刚好pip3过程需要ssl模块,而由于没有指定,所以该功能不可用。
安装openssl-devel
:
yum install -y openssl-devel
注意:openssl-devel
一定要在编译之前安装!!!
然后重新编译安装python3:
./configure --prefix=/usr/local/python3 --with-ssl
make
make install
然后重新安装:
(Py3_dev) [root@ onefinebin]# pip install -i https://pypi.doubanio.com/simple httpbin
Looking in indexes: https://pypi.doubanio.com/simple
Collecting httpbin
Downloading https://pypi.doubanio.com/packages/ff/dd/c988f90445763b0a09668209756fa89bbdc8590a8ade902f7dc69c36b26f/httpbin-0.7.0-py2.py3-none-any.whl (86kB)
100% |████████████████████████████████| 92kB 1.0MB/s
Requirement already satisfied: six in /root/.virtualenvs/Py3_dev/lib/python3.7/site-packages (from httpbin) (1.12.0)
Collecting brotlipy (from httpbin)
Downloading https://pypi.doubanio.com/packages/d9/91/bc79b88590e4f662bd40a55a2b6beb0f15da4726732efec5aa5a3763d856/brotlipy-0.7.0.tar.gz (413kB)
100% |████████████████████████████████| 419kB 44.0MB/s
...
就没问题了。
参考:
python pip 出现locations that require TLS/SSL异常处理方法 https://blog.csdn.net/zhengcaihua0/article/details/79681991