Search code examples
pythonpython-2.7importimporterrorsmtplib

Inconsistent import result


When I enter a python environment from my home directory and try to import smtplib I get the following error:

>>> import smtplib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/space/jazz/1/users/gwarner/anaconda/lib/python2.7/smtplib.py", line 46, in <module>
    import email.utils
  File "email.py", line 3, in <module>
    from email.mime.text import MIMEText
ImportError: No module named mime.text

My which python for my home directory is /space/jazz/1/users/gwarner/anaconda/bin/python. The strange thing is that I can successfully import smtplib from /space/jazz/1/users/gwarner/anaconda/lib/python2.7 even though my which python is the same as in my home directory. How can I get an error in the former but not in the latter if my path/which python doesn't change?


Solution

  • Looks like this problem to me.

    Don't you have any python script in your home directory (email.py in the previous link) overwriting some package ? If so, rename it.