简体   繁体   中英

Error installing python package with pip (TLSV1_ALERT_PROTOCOL_VERSION)

I'm on Suse Linux Enterprise 11 SP4 and I'm trying to install a python package using pip but it's failing with the following error:

Env:

$ 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)

Command:

$ pip install sendgrid

Error:

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

I have tried all this solutions but none of them had work on SLES.

Any ideas?

Thanks in advance

You can ignore SSL errors by setting pypi.org and files.pythonhosted.org as trusted hosts.

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

Or:

Try installing using the wheel of the package

Finally I get it to work!

Seems that the openssl library that came installed by default on SLES 11 SP4 ( libopenssl-devel ) is really outdated ( OpenSSL 0.9.8 )

To verify this you can run:

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

The trick is to uninstall libopenssl-devel and install libopenssl1-devel like this:

IMPORTANT: Note that you will be asked to take an option, please select deinstallation of 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]

Now procede to recompile/reinstall your python env with:

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

Finally verify that your OpenSSL version is the new one and proceed to install your package with pip :

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

$ pip install sendgrid

Hope it helps you!

Please see 'Security Module in SUSE Linux Enterprise 11' for more info

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM