py2exe does not work with the standard email module
Hello. I am trying to use py2exe for converting a script into an exe. The build process shows this:
The following modules appear to be missing
The executable does not work. The referenced modules are not included. I researched this on the Internet and I found out that py2exe has a problem with the Lazy import used in the standard lib email module. Unfortunately I have not succeeded in finding a workaround for this problem. Can anyone help?
Thank you,
P.S. Imports in the script look like this:
Code: Select all import string,time,sys,os,smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEBase import MIMEBase from email.MIMEText import MIMEText from email import Encoders
Have a look at this question how-to-package-twisted-program-with-py2exe it seems to be the same problem.
The answer given there is to explicitly include the modules on the command line to py2exe.
What version of Python are you using? If you are using 2.5 or 2.6, then you should be doing your import like:
import string,time,sys,os,smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email import Encoders
I'm pretty certain that py2exe's modulefinder can correctly find the email package if you use it correctly (i.e. use the above names in Python 2.5+, or use the old names in Python 2.4-). Certainly the SpamBayes setup script does not need to explicitly include the email package, and it includes the email modules without problem.
The other answers are correct in that if you do need to specifically include a module, you use the "includes" option, either via the command-line, or passing them in when you call setup.
Use the "includes" option. See: http://www.py2exe.org/index.cgi/ListOfOptions
If you don't have to work with py2exe, bbfreeze works better, and I've tried it with the email module. http://pypi.python.org/pypi/bbfreeze/0.95.4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With