Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named mime.multipart

Tags:

python

email

Good morning,

For testing purposes, I have made a one-line Python program:

from email.mime.multipart import MIMEMultipart

When I run it through the interpeter, I get an awful error message:

from email.mime.multipart import MIMEMultipart ImportError: No module named mime.multipart

I am using Python version 2.4.3. I suspect that the email module has changed its packaging structure in the intervening versions, hence the error. Is my suspicion correct? If not, why is the import statement not working?

Thanks in advance,
ktm

like image 400
ktm5124 Avatar asked Apr 28 '11 16:04

ktm5124


2 Answers

Module reorganization. The convention is for module names to be lower case, so some got renamed. In this case, the module you're looking for in Python 2.4.3 is email.MIMEMultipart.

Here's the docs from back then, in case the API has changed.

like image 164
Rafe Kettler Avatar answered Sep 22 '22 15:09

Rafe Kettler


Call me dumb, but I was getting ImportError: No module named mime.text because my script was called email.py .... lol (blame on 4 am programming)

like image 28
Shadi Avatar answered Sep 23 '22 15:09

Shadi