ImportError: cannot import name 'Enum'

Chris Angelico rosuav at gmail.com
Sun Nov 23 13:20:01 CET 2014


On Sun, Nov 23, 2014 at 11:10 PM,  <muhammedabuali at gmail.com> wrote:
> Hello all,
>
> I am trying to use the python module but when I open the shell and write:
>
> ` import enum `
>
> I get the following error
>
> ` Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/lib/python3.4/enum.py", line 3, in <module>
>     from types import MappingProxyType, DynamicClassAttribute
>   File "/home/muhammed/workspace/python/unification/types.py", line 1, in <module>
>     from enum import Enum
> ImportError: cannot import name 'Enum'

Thank you for making it so clear and easy! By posting the entire
traceback, plus everything you're expecting to see, you clearly show
what's going on. THANK YOU!

What's happening here is that you have a file called "types.py".
Unfortunately that name shadows the 'types' module in the standard
library, and enum calls on that. So you'll need to rename your file,
and then all should be well.

ChrisA



More information about the Python-list mailing list