pip is configured with locations that require TLS/SSL問題


linux 6 安裝python3.7后,使用pip命令出現問題,提示找不到ssl模塊,出現錯誤如下

# pip list
Package Version
---------- -------
pip 10.0.1
setuptools 39.0.1
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版本

# pip --version
pip 10.0.1 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)
# pip list
Package    Version
---------- -------
pip        10.0.1 
setuptools 39.0.1 
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

 

經百度查詢,系統centos6.5后,其中openssl的版本為

# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013

而python3.7需要的openssl的版本為1.0.2或者1.1.x,需要對openssl進行升級,並重新編譯python3.7.0。yum 安裝的openssl 版本都比較低。

 

升級openssl

下載編譯安裝

# wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz
...
# tar -zxvf openssl-1.1.1a.tar.gz
...
# cd openssl-1.1.1a 
# ./config --prefix=/usr/local/openssl no-zlib
Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1a (0x1010101fL) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL file first)         ***
***                                                                ***
**********************************************************************
[root@centos6 openssl-1.1.1a]# echo $?
0
# make && make install

備份原配置文件

# mv /usr/bin/openssl /usr/bin/openssl.bak
# mv /usr/include/openssl/ /usr/include/openssl.bak

新版設置

# ln -s /usr/local/openssl/include/openssl /usr/include/openssl
# ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/local/lib64/libssl.so
# ln -s  /usr/local/openssl/bin/openssl /usr/bin/openssl

修改系統配置,寫入openssl庫文件的搜索路徑

# echo '/usr/local/openssl/lib' >> /etc/ld.so.conf

使修改后的/etc/ld.so.conf生效

# ldconfig -v

查看版本

# openssl version
OpenSSL 1.1.1a  20 Nov 2018

 

需要重新編譯安裝python

# ./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
...
# make && make install

 

再次使用pip

# pip list
Package    Version
---------- -------
pip        10.0.1 
setuptools 39.0.1 
You are using pip version 10.0.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

升級pip

# pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 13kB/s 
Installing collected packages: pip
  Found existing installation: pip 10.0.1
    Uninstalling pip-10.0.1:
      Successfully uninstalled pip-10.0.1
Successfully installed pip-19.3.1

 

嘗試pip安裝

# pip install matplotlib
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/matplotlib/
Collecting matplotlib
  Downloading https://files.pythonhosted.org/packages/61/42/3e92d7aa64295483fbca20a86c89b34d0cb43cffaadaffe028793902d790/matplotlib-3.1.2-cp37-cp37m-manylinux1_x86_64.whl (13.1MB)
     |                                | 30kB 4.9kB/s eta 0:44:56ERROR: Exception:
Traceback (most recent call last):
  File "/usr/local/python3/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 425, in _error_catcher

可以下載安裝,只是我的網絡不行,下載不了。。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM