Skip to content Skip to sidebar Skip to footer

Python - Py2exe Can't Build .exe Using The 'email' Module

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 appea

Solution 1:

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.

Solution 2:

What version of Python are you using? If you are using 2.5 or 2.6, then you should be doing your import like:

importstring,time,sys,os,smtplib
from email.mime.multipartimportMIMEMultipartfrom email.mime.baseimportMIMEBasefrom email.mime.textimportMIMETextfrom email importEncoders

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.

Solution 3:

Use the "includes" option. See: http://www.py2exe.org/index.cgi/ListOfOptions

Solution 4:

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

Solution 5:

I got it working by explicitly including missing modules in setup.py:

OLD setup.py:

setup(console = ['main.py'])

New setup.py:

setup(console = ['main.py'], 
      options={"py2exe":{"includes":["email.mime.multipart","email.mime.text"]}})

Post a Comment for "Python - Py2exe Can't Build .exe Using The 'email' Module"