Cryptography: Handle having the "enum" package installed better

Created on 3 Nov 2017  路  5Comments  路  Source: pyca/cryptography

After upgrading the cryptography module with pip, the Python OpenSSL wrapper doesn't work properly any more on my system because an import from cryptography fails. I could recreate this in a naked Python REPL, so it doesn't look like it has anything to do with OpenSSL per se?:

>>> from cryptography import x509
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/__init__.py", line 8, in <module>
    from cryptography.x509.base import (
  File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/base.py", line 16, in <module>
    from cryptography.x509.extensions import Extension, ExtensionType
  File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/extensions.py", line 24, in <module>
    from cryptography.x509.general_name import GeneralName, IPAddress, OtherName
  File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/general_name.py", line 18, in <module>
    from cryptography.x509.name import Name
  File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/name.py", line 28, in <module>
    _ASN1_TYPE_TO_ENUM = dict((i.value, i) for i in _ASN1Type)
TypeError: 'type' object is not iterable
>>> 
>>> import cryptography
>>> cryptography.__version__
'2.1.3'
>>> 
installation

Most helpful comment

Found out why it happened. My system had this enum package installed: https://pypi.python.org/pypi/enum

But it looks like the cryptography code needs the Python 3 enum, or its backport for 2.7: https://pypi.python.org/pypi/enum34

All 5 comments

Found out why it happened. My system had this enum package installed: https://pypi.python.org/pypi/enum

But it looks like the cryptography code needs the Python 3 enum, or its backport for 2.7: https://pypi.python.org/pypi/enum34

Yeah that's right. Unfortunately I don't think there's a way around this.

No problem for me, easy enough to update to enum34. For other users who may run into the same problem, I suppose a version check and abort on detecting a non-conforming version would be a nice way to handle it.

@MortenEriksen
Thanks your solution.
"pip install enum34" could fixed my question.
you are so nice.

The ecosystem appears to have resolved this issue, so we're not going to add an explicit workaround.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kamikaze picture kamikaze  路  7Comments

BobbyGR picture BobbyGR  路  5Comments

trishankatdatadog picture trishankatdatadog  路  4Comments

rahulraghu94 picture rahulraghu94  路  4Comments

leesunkeuy picture leesunkeuy  路  8Comments