Prev: logging: AttributeError: 'module' object has no attribute 'getLogger'
Next: Can upper() or lower() ever change the length of a string?
From: dirknbr on 24 May 2010 07:56 I am trying to run from email.mime.text import MIMEText but I get an ImportError: No module named mime.text Since email was pre-installed how do I fix this? Dirk
From: Jean-Michel Pichavant on 24 May 2010 09:19 dirknbr wrote: > I am trying to run > > from email.mime.text import MIMEText > > but I get an > > ImportError: No module named mime.text > > Since email was pre-installed how do I fix this? > > Dirk > Did you make sure you didn't hide the standard email module by one of your own. Check print email.__file__ /usr/lib/python2.5/email/__init__.pyc If the path is correct, you may want to look in the code, or if anything has changed in 2.6, I guess it is documented somewhere. JM
From: dirknbr on 24 May 2010 09:59 I have now easy_installled email and I still get errors. It doesn't error on 'import email' but does on call to MimeText. import email msg = MIMEText('test') NameError: name 'MIMEText' is not defined What should I do?
From: Simon Brunning on 24 May 2010 10:21 On 24 May 2010 14:59:24 UTC+1, dirknbr <dirknbr(a)googlemail.com> wrote: > It doesn't error on 'import email' but does on call to MimeText. > > import email > msg = MIMEText('test') > > NameError: name 'MIMEText' is not defined Here you want: msg = email.MIMEText('test') -- Cheers, Simon B.
From: Jean-Michel Pichavant on 24 May 2010 10:22
dirknbr wrote: > I have now easy_installled email and I still get errors. > > It doesn't error on 'import email' but does on call to MimeText. > > import email > msg = MIMEText('test') > > NameError: name 'MIMEText' is not defined > > What should I do? > Using easy_install will not prevent the standard lib to be shadowed by another (user) module. did you print email.__file__ to verify the path ? Can you show us the output ? To give you an example, on a lenny python 2.5 distrib, the MIMEText class is in /usr/lib/python2.5/email/mime/text.py JM |