17

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'
7
  • You should try : pip install -U cryptography Commented Dec 12, 2016 at 13:47
  • Same error even to get cryptography installed. Commented Dec 12, 2016 at 13:48
  • It seems that something related to SSL is missing. You probably should upgrade your pip (never know) : pip install --upgrade pip and then try to pip OpenSSL with : pip install pyOpenSSL Commented Dec 12, 2016 at 13:53
  • @FlorianJOUFFREAU even to upgrade pip it is showing same error. Commented Dec 12, 2016 at 13:57
  • 1
    uninstall pip and reinstall it. sudo apt-get purge python-pip Commented Dec 12, 2016 at 14:19

9 Answers 9

35

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks, but I needed to do pip install pyopenssl.
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
@M-Jack Perhaps it's better to not use --auto-remove then?
Not sure... I have tried only your solution. But it is probably important to reinstall then the packages that have been removed.
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...
|
12

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

2 Comments

Didn't work for me, unfortunately. Brings back the same error after reinstalling. I'm on Ubuntu 16.04.3
@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.
4

If even pip is not working then try following:

sudo easy_install -U cffi
sudo easy_install -U cryptography

It works for me.

Comments

2

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

2

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

Comments

2

Try to do the following:

$ rm -rf /home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL
$ rm -rf /home/ubuntu/.local/lib/python2.7/site-packages/pyOpenSSL-0.15.1.egg-info

In the last line, you might have another version of pyOpenSSL, specify yours.

1 Comment

I needed to delete it from both directories /usr/lib and /usr/local/lib then reinstalling cryptography==2.6.1 and pyopenssl==19.0.0 on ubuntu 20.04. I installed it using pip3.
1

Quick Fix

Move the OpenSSL folder to OpenSSLBAK (for instance) to avoid the error

# cd /usr/lib/python2.7/dist-packages
# mv OpenSSL OpenSSLBAK

It should be good

Comments

0

Try reinstalling python of which will fix many of your problems,do

sudo apt-get install --reinstall python2.7

and pip will be missing after reinstalling,do

sudo apt-get install python-pip

2 Comments

how many pip directory do you have at /usr/lib/python2.7/site-packages/??
Anyway,go to the path i mentioned above,,delete manual any pip directory you find then do python get-pip.py again
-1

Try to download the suitable wheel file from here depending in your operating system and python version. Then add this file to Python/Scripts and use the code below to install it.

pip install nameofwheelfile.whl

The wheel file contains all the dependencies.

5 Comments

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.
OK. If you try as a sudo user do you get the same error as well?
YES same result
Hm.. Did you try to upgrade pip?
That link is for windows python libs, the question is tagged with linux and ubuntu so that won't help much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.