Pipenv: Broken pipenv after update: AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

Created on 5 Oct 2017  路  8Comments  路  Source: pypa/pipenv

After:

$ sudo pip install -U pipenv
...
ackages (from pew>=0.1.26->pipenv)
Installing collected packages: pew, pipenv
  Found existing installation: pew 0.1.26
    Uninstalling pew-0.1.26:
      Successfully uninstalled pew-0.1.26
  Found existing installation: pipenv 8.2.5
    Uninstalling pipenv-8.2.5:
      Successfully uninstalled pipenv-8.2.5
Successfully installed pew-0.1.27 pipenv-8.2.6

I couldn't use pipenv:

$ pipenv shell
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 7, in <module>
    from pipenv import cli
  File "/usr/local/lib/python2.7/dist-packages/pipenv/__init__.py", line 17, in <module>
    from .cli import cli
  File "/usr/local/lib/python2.7/dist-packages/pipenv/cli.py", line 21, in <module>
    import requests
  File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 84, in <module>
    from urllib3.contrib import pyopenssl
  File "/usr/local/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in <module>
    SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
$ pipenv --jumbotron
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 7, in <module>
    from pipenv import cli
  File "/usr/local/lib/python2.7/dist-packages/pipenv/__init__.py", line 17, in <module>
    from .cli import cli
  File "/usr/local/lib/python2.7/dist-packages/pipenv/cli.py", line 21, in <module>
    import requests
  File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 84, in <module>
    from urllib3.contrib import pyopenssl
  File "/usr/local/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in <module>
    SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

Most helpful comment

I uninstalled requests and pipenv and then I reinstalled both, but the problem still happening. I did some research and I found that the problem was pyOpenSSL. I remove that lib and reinstalled:
sudo pip install -U pyOpenSSL
Now pipenv works!

All 8 comments

Do you have requests[security] installed globally?

I have requests globally. Security, I don't know.

 ~  pip freeze | grep requests
requests==2.18.4

Can you uninstall requests and then reinstall pipenv? I think you have the the security package installed which is causing some issues with OpenSSL?

I uninstalled requests and pipenv and then I reinstalled both, but the problem still happening. I did some research and I found that the problem was pyOpenSSL. I remove that lib and reinstalled:
sudo pip install -U pyOpenSSL
Now pipenv works!

this fixed my virt-manager

Traceback (most recent call last):
File "/usr/share/virt-manager/virt-manager", line 34, in
from virtinst import util as util
File "/usr/share/virt-manager/virtinst/__init__.py", line 87, in
from virtinst.distroinstaller import DistroInstaller
File "/usr/share/virt-manager/virtinst/distroinstaller.py", line 26, in
from . import urlfetcher
File "/usr/share/virt-manager/virtinst/urlfetcher.py", line 27, in
import requests
File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 84, in
from urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 46, in
import OpenSSL.SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in
from OpenSSL import rand, crypto, SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

Solution:
pip uninstall pyOpenSSL

I saw the AttributeError: 'module' object has no attribute 'SSL_ST_INIT' error too and sudo pip install pyOpenSSL==16.2.0 resolved it for me!

well glad that fixed it!

We are getting exactly same issue with pipenv-11.6.0

pipenv --three install
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 1063, in invoke
    Command.invoke(self, ctx)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/cli.py", line 62, in cli
    from . import core
  File "/usr/local/lib/python2.7/dist-packages/pipenv/core.py", line 22, in <module>
    import requests
  File "/usr/local/lib/python2.7/dist-packages/pipenv/../requests/__init__.py", line 84, in <module>
    from urllib3.contrib import pyopenssl
  File "/usr/local/lib/python2.7/dist-packages/pipenv/../urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in <module>
    SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

Uninstall of pyOpenSSL seems to solve the issue but I am not suer if this is a right way to solve it.

pip uninstall -y pyOpenSSL
...
Successfully uninstalled pyOpenSSL-0.15.1
Was this page helpful?
0 / 5 - 0 ratings

Related issues

konstin picture konstin  路  3Comments

Californian picture Californian  路  3Comments

jacebrowning picture jacebrowning  路  3Comments

xi picture xi  路  3Comments

erinxocon picture erinxocon  路  3Comments