PyCharm / Django Setup: Can't import encoding from email?
I was asked to contribute to some production Python / Django code. I am setting it up in PyCharm. When I run the application, I receive the following error message:
File "/myApp/myVirtualEnvironment/lib/python2.7/site-packages/django/core/mail/message.py",
line 8, in <module>
from email import (charset as Charset, encoders as Encoders)
ImportError: cannot import name charset
What could be causing this?
source to share
This could be caused by a name-tracking trap .
The reason may be that you are hiding the Charset class , which is defined in the email.charset module on import from email import (charset as Charset, encoders as Encoders)
.
Another likely cause supported by this issue :
If you check your file tree, you may find a file named charset.py
or charset.py
that obscures the above
Find your files and you will find what casts a shadow.
source to share