Python AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

Update your pyopenssl module:

$ sudo pip install -U pyopenssl

Upgrading pyopenssl with pip was not working as none of the commands related to to pip was working for me. By upgrading pyopenssl with easy_install, above problem can be solved.

sudo python -m easy_install --upgrade pyOpenSSL

credit @delimiter (Answer)


Turned out the problem was with my installation of pyOpenSSL, pyOpenSSL-0.15.1 .

I did:

pip uninstall pyopenssl

and then

pip install pyopenssl

...and my Python script worked again!


I had a similar error:

    from OpenSSL import rand, crypto, SSL
  File "/usr/local/lib/python3.5/dist-packages/OpenSSL/SSL.py", line 112, in <module>
    SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: module 'lib' has no attribute 'SSL_ST_INIT'

and none of the other answers could fix it, because pip could not install anything. Instead, what I did was this from the terminal first:

sudo rm -r /usr/local/lib/python3.5/dist-packages/OpenSSL

Then reinstalled pyopenssl with pip:

sudo pip install pyopenssl

and everything was gravy.