How to fix Python ImportError: cannot import name 'enum'
Problem:
You have a line like this in your Python code:
enum_import_example.py
from enum import EnumBut when you try to run it, you see this error message:
example.txt
Traceback (most recent call last):
File "test.py", line 1, in <module>
from enum import Enum
ImportError: No module named enumSolution
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
install_enum34.sh
pip install -U enum34After installing this, the ImportError should disappear.
Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow