簡體   English   中英

使用pip安裝python軟件包時出錯(TLSV1_ALERT_PROTOCOL_VERSION)

[英]Error installing python package with pip (TLSV1_ALERT_PROTOCOL_VERSION)

我在Suse Linux Enterprise 11 SP4上,並嘗試使用pip安裝python軟件包,但失敗並出現以下錯誤:

信封:

$ python --version
Python 3.6.6

$ pip --version
pip 10.0.1 from /home/<<user>>/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pip (python 3.6)

命令:

$ pip install sendgrid

錯誤:

Collecting sendgrid
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:841)'),)': /simple/sendgrid/
...
...
  Could not fetch URL https://pypi.org/simple/sendgrid/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/sendgrid/ (Caused by SSLError(SSLError(1, '[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:841)'),)) - skipping
  Could not find a version that satisfies the requirement sendgrid (from versions: )
No matching distribution found for sendgrid
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(SSLError(1, '[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:841)'),)) - skipping

我已經嘗試了所有這些解決方案,但是沒有一個在SLES上起作用。

有任何想法嗎?

提前致謝

您可以通過將pypi.org和files.pythonhosted.org設置為可信主機來忽略SSL錯誤。

pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package_name>

要么:

嘗試使用包裝箱的輪子進行安裝

終於,我開始工作了!

似乎默認在SLES 11 SP4上安裝的openssl庫( libopenssl-devel )確實過時了( OpenSSL 0.9.8

要驗證這一點,您可以運行:

$ python -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 0.9.8j-fips 07 Jan 2009

訣竅是卸載 libopenssl-devel安裝 libopenssl1-devel如下所示:

重要提示:請注意,系統會要求您選擇一個選項,請選擇卸載libopenssl-devel-0.9.xx.xxx.xxx

$ sudo zypper install libopenssl1-devel

Loading repository data...
Reading installed packages...
Resolving package dependencies...

Problem: libopenssl1-devel-1.0.1g-0.58.9.1.x86_64 conflicts with libopenssl-devel < 1.0.1 provided by libopenssl-devel-0.9.8j-0.106.9.1.x86_64
 Solution 1: deinstallation of libopenssl-devel-0.9.8j-0.106.9.1.x86_64
 Solution 2: do not install libopenssl1-devel-1.0.1g-0.58.9.1.x86_64

Choose from above solutions by number or cancel [1/2/c] (c): 1
Resolving dependencies...
Resolving package dependencies...

The following NEW package is going to be installed:
  libopenssl1-devel 

The following package is going to be REMOVED:
  libopenssl-devel 

1 new package to install, 1 to remove.
Overall download size: 3.3 MiB. After the operation, 698.0 KiB will be freed.
Continue? [y/n/? shows all options] (y): 
Retrieving package libopenssl1-devel-1.0.1g-0.58.9.1.x86_64 (1/1), 3.3 MiB (19.6 MiB unpacked)
Retrieving: libopenssl1-devel-1.0.1g-0.58.9.1.x86_64.rpm [done]
Removing libopenssl-devel-0.9.8j-0.106.9.1 [done]
Installing: libopenssl1-devel-1.0.1g-0.58.9.1 [done]

現在繼續使用以下命令重新編譯/重新安裝您的python env:

$ CFLAGS=-I/usr/include/openssl1 LDFLAGS=-L/usr/lib64 pyenv install 3.6.6

最后,確認您的OpenSSL版本是新版本,然后繼續使用pip安裝軟件包:

$ python -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 1.0.1g 7 Apr 2014

$ pip install sendgrid

希望對您有幫助!

有關更多信息,請參見“ SUSE Linux Enterprise 11中的安全模塊”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM