Pip Error : 'module' object has no attribute 'Cryptography_HAS_SSL_ST'

28,881

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!

Share:
28,881
SaiKiran
Author by

SaiKiran

Programmer

Updated on August 02, 2022

Comments

  • SaiKiran
    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
    SaiKiran over 7 years
    Problem 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
    Arduino_Sentinel over 7 years
    how many pip directory do you have at /usr/lib/python2.7/site-packages/??
  • Arduino_Sentinel
    Arduino_Sentinel over 7 years
    Anyway,go to the path i mentioned above,,delete manual any pip directory you find then do python get-pip.py again
  • zinon
    zinon over 7 years
    OK. If you try as a sudo user do you get the same error as well?
  • SaiKiran
    SaiKiran over 7 years
    YES same result
  • zinon
    zinon over 7 years
    Hm.. Did you try to upgrade pip?
  • bschlueter
    bschlueter over 7 years
    That link is for windows python libs, the question is tagged with linux and ubuntu so that won't help much.
  • Mahendar Patel
    Mahendar Patel over 6 years
    Didn't work for me, unfortunately. Brings back the same error after reinstalling. I'm on Ubuntu 16.04.3
  • bschlueter
    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
    Gerhard Hagerer over 6 years
    Thanks, but I needed to do pip install pyopenssl.
  • M-Jack
    M-Jack about 6 years
    Also on Ubuntu 16.04.3 : apt-get --auto-remove --yes remove python-openssl removes a lot of dependencies packages ! including landscape-common, python-qt4 and oneconf. I had to reinstall them after issuing this command : apt install landscape-common python-qt4 oneconf and then finally pip install pyopenssl
  • Mahendar Patel
    Mahendar Patel about 6 years
    @M-Jack Perhaps it's better to not use --auto-remove then?
  • M-Jack
    M-Jack about 6 years
    Not sure... I have tried only your solution. But it is probably important to reinstall then the packages that have been removed.
  • Brendan Dolan-Gavitt
    Brendan Dolan-Gavitt over 5 years
    It 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
    Mahendar Patel over 5 years
    Due to feedback I've changed my answer to ask for confirmation.