2

With pip on Ubuntu 14.04, I am getting this error:

Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "/usr/lib/python2.7/dist-packages/pip/_vendor/__init__.py", line 64, in <module>
vendored("cachecontrol")
File "/usr/lib/python2.7/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
__import__(modulename, globals(), locals(), level=0)
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/__init__.py", line 9, in <module>
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/wrapper.py", line 1, in <module>
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 4, in <module>
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/__init__.py", line 52, in <module>
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/packages/__init__.py", line 59, in <module>
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/packages/__init__.py", line 32, in vendored
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 47, in <module>
File "/usr/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

How can I solve this?

Zanna
  • 70,465
queez
  • 41

5 Answers5

2

Use pip3

I had to switch over to using pip3 to resolve this issue:

$ sudo pip3 install --upgrade pyopenssl

Serge Stroobandt
  • 5,268
  • 1
  • 48
  • 59
1

I found that this answer on stackoverflow helped. Basically, it says that you should do this:

rm -rf /home/<Your Username>/.local/lib/python2.7/site-packages/OpenSSL
sudo rm -rf usr/local/lib/python2.7/dist-packages/OpenSSL/
pip install pyOpenSSL
0

yeah pip errors until you fix it manually (chicken and egg mentioned)....find where the library is installed and manually delete it.

On my 16.04 installation I did this:

cd /usr/lib/python2.7/dist-packages
rm -rf OpenSSL

Then pip worked correctly without the SSL error

pip install pyopenssl

Beerman
  • 109
  • 2
    Removing packages manually from /usr/lib/python*/dist-packagescan be dangerous as it may break package updates from OpenSSL that provide the Python libraries. You should refrain from manually removing files from package-manager-controlled directories when you can. – Thomas Ward Jul 10 '18 at 14:24
  • works in WSL too. – vijay v Apr 05 '20 at 13:05
0

Try this:

sudo apt-get update    
sudo easy_install -U cryptography

Then install pyopenssl package:

pip install pyopenssl

I hope this works. Cheers!

Vikas Yadav
  • 101
  • 2
-2

You are missing pyOpenSSL package, or is outdated.

simply run

$ pip install pyopenssl

and update packages (may not be necessary).

chazecka
  • 368