AttributeError: module 'lib' has no attribute 'SSL_ST_INIT'

I wanted to upgrade pip but I couldn't by the following error:

sudo pip install --upgrade pip 
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip._internal import main
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/__init__.py", line 42, in <module>
    from pip._internal import cmdoptions
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
    from pip._internal.index import (
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/index.py", line 14, in <module>
    from pip._vendor import html5lib, requests, six
  File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/requests/__init__.py", line 97, in <module>
    from pip._vendor.urllib3.contrib import pyopenssl
  File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 118, in <module>
    SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: module 'lib' has no attribute 'SSL_ST_INIT'

Reading forums I found that best solution is upgrade or uninstall pyOpenSSL to install pyOpenSSL version 16.2.0. First I tried upgrade it, but without solution.

sudo python -m easy_install --upgrade pyOpenSSL

Secondly, I tried to remove it, but I couldn't. I get the same error:

sudo pip uninstall -y pyOpenSSL
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip._internal import main
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/__init__.py", line 42, in <module>
    from pip._internal import cmdoptions
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
    from pip._internal.index import (
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/index.py", line 14, in <module>
    from pip._vendor import html5lib, requests, six
  File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/requests/__init__.py", line 97, in <module>
    from pip._vendor.urllib3.contrib import pyopenssl
  File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 118, in <module>
    SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: module 'lib' has no attribute 'SSL_ST_INIT'

The last option is delete the folder that contains it and install the specific version:

sudo rm -r /usr/lib/python3/dist-packages/OpenSSL/ 
sudo pip install pyOpenSSL==16.2.0

Now it works
Enjoy it!

Comments

Popular posts from this blog

Exception: Could not find a default OpenFlow controller in Mininet

How to fix Android when developer options are not available for this user

Webcam streaming throught VLC with YUY2 compatibility