Email in 2.6.4

D

dirknbr

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
 
J

Jean-Michel Pichavant

dirknbr said:
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
 
D

dirknbr

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?
 
S

Simon Brunning

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')
 
J

Jean-Michel Pichavant

dirknbr said:
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
 
M

Mark Lawrence

I have now easy_installled email and I still get errors.
I've done this as well, but don't see why I have to. Is this a
documentation bug, an installation bug or what?
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?
Give the fully qualified name i.e. email.mime.text.MIMEText.

Regards.

Mark Lawrence.
 
J

Jean-Michel Pichavant

Dirk said:
Sorry guys, I had named my file email.py and hence the error.



On 24 May 2010 15:22, Jean-Michel Pichavant <[email protected]

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
Classic error, you're not the first one, and my guess is that you won't
be the last.

JM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top