Pip Error : 'module' object has no attribute 'Cryptography_HAS_SSL_ST'
Solution 1
Ubuntu 16.04.3 here:
I think I have fixed this by removing the python-openssl package (and it's dependencies) with:
apt-get --auto-remove remove python-openssl
Then installing the latest version with pip:
pip install pyOpenSSL
Of course, if you install another apt package that depends on it, it'll pull it back in. I hope if you use pip for everything you can from now on instead of apt, it should be fine.
Edit: as of January 2019 this issue doesn't seem to exist any more.
Solution 2
I was able to resolve this by deleting the openssl python lib and reinstalling (purge before install did not work):
$ sudo rm -rf /usr/local/lib/python2.7/dist-packages/OpenSSL/
$ sudo apt install --reinstall python-openssl
Solution 3
If even pip is not working then try following:
sudo easy_install -U cffi
sudo easy_install -U cryptography
It works for me.
Solution 4
I got this error and solved it by doing these steps (don't forget to put your own username):
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
Solution 5
To fix it on RHEL/CentOS:
sudo rm -rf /usr/lib/python2.7/site-packages/OpenSSL/
sudo yum install pyOpenSSL
This did it for me on CentOS 7. Cheers!
Comments
-
SaiKiran almost 2 years
I tried to install from pip and keep on getting similar type of errors.
$ pip install quandl Traceback (most recent call last): File "/usr/bin/pip", line 9, in <module> load_entry_point('pip==1.5.6', 'console_scripts', 'pip')() File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 558, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2682, in load_entry_point return ep.load() File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2355, in load return self.resolve() File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2361, in resolve module = __import__(self.module_name, fromlist=['__name__'], level=0) File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in <module> from pip.vcs import git, mercurial, subversion, bazaar # noqa File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module> from pip.download import path_to_url File "/usr/lib/python2.7/dist-packages/pip/download.py", line 22, in <module> import requests, six File "/usr/lib/python2.7/dist-packages/requests/__init__.py", line 53, in <module> from .packages.urllib3.contrib import pyopenssl File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 53, in <module> import OpenSSL.SSL File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module> from OpenSSL import rand, crypto, SSL File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 112, in <module> if _lib.Cryptography_HAS_SSL_ST: AttributeError: 'module' object has no attribute 'Cryptography_HAS_SSL_ST'
Now even though i tried to install different pip modules iam getting same error.Is there any solution for this ? This was caused due to the unexpected killing of the process while a pip module is being downloaded.
Please help me with the necessary steps to rectify this error.
I tried to install this
$ pip install -U cryptography Traceback (most recent call last): File "/usr/bin/pip", line 9, in <module> load_entry_point('pip==1.5.6', 'console_scripts', 'pip')() File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 558, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2682, in load_entry_point return ep.load() File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2355, in load return self.resolve() File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2361, in resolve module = __import__(self.module_name, fromlist=['__name__'], level=0) File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in <module> from pip.vcs import git, mercurial, subversion, bazaar # noqa File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module> from pip.download import path_to_url File "/usr/lib/python2.7/dist-packages/pip/download.py", line 22, in <module> import requests, six File "/usr/lib/python2.7/dist-packages/requests/__init__.py", line 53, in <module> from .packages.urllib3.contrib import pyopenssl File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 53, in <module> import OpenSSL.SSL File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module> from OpenSSL import rand, crypto, SSL File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 112, in <module> if _lib.Cryptography_HAS_SSL_ST: AttributeError: 'module' object has no attribute 'Cryptography_HAS_SSL_ST'
-
SaiKiran over 7 yearsProblem is not only for a specific module,i can do this method.But real problem is it is not working for any module.Even i enter
pip
it produces the same results. -
Arduino_Sentinel over 7 yearshow many
pip
directory do you have at/usr/lib/python2.7/site-packages/
?? -
Arduino_Sentinel over 7 yearsAnyway,go to the path i mentioned above,,delete manual any pip directory you find then do
python get-pip.py
again -
zinon over 7 yearsOK. If you try as a sudo user do you get the same error as well?
-
SaiKiran over 7 yearsYES same result
-
zinon over 7 yearsHm.. Did you try to
upgrade pip
? -
bschlueter over 7 yearsThat link is for windows python libs, the question is tagged with
linux
andubuntu
so that won't help much. -
Mahendar Patel over 6 yearsDidn't work for me, unfortunately. Brings back the same error after reinstalling. I'm on Ubuntu 16.04.3
-
bschlueter over 6 years@AsfandQazi you should confirm that's the python you're using and the potential location for other methods of installation for the lib.
python -c 'import sys; print(sys.path)'
will let you know where to look. -
Gerhard Hagerer over 6 yearsThanks, but I needed to do
pip install pyopenssl
. -
M-Jack about 6 yearsAlso on Ubuntu 16.04.3 :
apt-get --auto-remove --yes remove python-openssl
removes a lot of dependencies packages ! includinglandscape-common
,python-qt4
andoneconf
. I had to reinstall them after issuing this command :apt install landscape-common python-qt4 oneconf
and then finallypip install pyopenssl
-
Mahendar Patel about 6 years@M-Jack Perhaps it's better to not use --auto-remove then?
-
M-Jack about 6 yearsNot sure... I have tried only your solution. But it is probably important to reinstall then the packages that have been removed.
-
Brendan Dolan-Gavitt over 5 yearsIt is probably not a good idea to tell people to run a command that removes a package which many other packages depend on, especially with flags that auto-confirm! This ended up removing over 700 packages from my system...
-
Mahendar Patel over 5 yearsDue to feedback I've changed my answer to ask for confirmation.