AttributeError: module ‘enum’ has no attribute ‘intflag’ error occurs when the ‘enum34’ module is installed in your system, conflicting with the default enum class.
To fix the error, “uninstalling the enum34 module” or “upgrading to a newer version of Python”.
Since Python version 3.6, the enum34 library doesn’t work with the standard library. However, you don’t need the library, so you can uninstall it.
To uninstall the enum module, you can use the below command.
pip uninstall -y enum34
python3 -m pip uninstall -y enum34
pip3 uninstall -y enum34
Causes of the error
- Incorrect or outdated Python version
- Corrupted Python installation
- If there is a file or module in your project or Python path named enum.py, it could be shadowing the standard library’s enum module. This is a common issue when a file inadvertently has the same name as a standard library module.
The “intflag” attribute was introduced in Python 3.4, so if you are using an earlier version, upgrading to a newer version that includes this attribute should fix the error.
You can inspect the enum module by printing the property enum.__file__.
If none of the suggestions helped, try to unset the PYTHONPATH environment variable.
Ensure you don’t have a file named enum.py in your Python project because it would override the built-in enum module.
You have to rename or remove the file if you have one.