pip crashes at startup importing from OpenSSL

Bug #1733311 reported by Eero Aaltonen
30
This bug affects 6 people
Affects Status Importance Assigned to Milestone
pyopenssl (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

For python-openssl Version: 0.15.1-2build1 on Ubuntu 16.04

'pip' (and other commands) importing from OpenSSL crash with the following traceback

$ pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 13, in <module>
    from pip.exceptions import InstallationError, CommandError, PipError
  File "/usr/lib/python2.7/dist-packages/pip/exceptions.py", line 6, in <module>
    from pip._vendor.six import iteritems
  File "/usr/lib/python2.7/dist-packages/pip/_vendor/__init__.py", line 64, in <module>
    vendored("cachecontrol")
  File "/usr/lib/python2.7/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
    __import__(modulename, globals(), locals(), level=0)
  File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/__init__.py", line 9, in <module>
  File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/wrapper.py", line 1, in <module>
  File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/adapter.py", line 3, in <module>
  File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/__init__.py", line 53, in <module>
  File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 54, in <module>
  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'

By googling the last line, it seems many people are experiencing this problem (an example https://stackoverflow.com/questions/43267157/python-attributeerror-module-object-has-no-attribute-ssl-st-init).

Tags: xenial
tags: added: xenial
Revision history for this message
Adam Gandelman (gandelman-a) wrote :

Just started hitting this as well. Simply importing the OpenSSL library raises the AttributeError:

adam@amebix:~$ python -c 'import OpenSSL'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  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'
adam@amebix:~$

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in pyopenssl (Ubuntu):
status: New → Confirmed
Revision history for this message
Koen Smets (ksmets) wrote :

I experience the same issue after upgrading from 14.04.5 to 16.04.3. Other server where 16.04.3 has been installed from fresh doesn't have the issue.

Revision history for this message
Koen Smets (ksmets) wrote :

I discovered the root cause of the issue by comparing the output of `pip freeze` on both servers.

Apparently on the upgraded server cryptography-1.9 was installed in `/usr/local/python2.7/dist-packages`, while overriding python-cryptography package.

Running `sudo pip uninstall cryptography` resolves the issue.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.