How to fix Python ImportError: cannot import name 'enum'


You have a line like this in your Python code:

from enum import Enum

But when you try to run it, you see this error message:

Traceback (most recent call last):
  File "", line 1, in <module>
    from enum import Enum
ImportError: No module named enum


The enum module is only available in Python 3, but you are using Python 2!

You can try to run your script using Python 3. In case that’s not possible (because your project or a library is not compatible with Python 3), you can install the enum34 backport

sudo pip install enum34

After installing this, the ImportError should disappear.