Thursday, July 31, 2008

Py2exe and email.generator, email.blah blah errors

Create this file :-

import email
msg = email.MIMEText.MIMEText("dsafdafdasfA")
print "ok"

Create setup.py like below :

from distutils.core import setup
import py2exe
setup(console=['testmime.py'])


Run python setup.py py2exe and you will get errors

The following modules appear to be missing['email.Generator', 'email.Iterators', 'email.Utils']

And your program will bombed out with errors like ""Import error : No module name text"


To solve this i just added " print self.__name__" under __init__.py of \email package.
And it seems the LazyImporter is confusing py2exe.

Solution ?

import email
import email.mime.text
import email.iterators
import email.generator
import email.utils

5 comments:

  1. Hi!!

    Did you get a solution for this problem?? I have right the same issue!!

    Thank you!

    ReplyDelete
  2. The solution is as written at the end of the posting. just import those at the top of ur module.

    ReplyDelete
  3. I'm using python 2.6 and this solution does not work for me. Any other ideas?

    ReplyDelete
  4. try bbfreeze.
    Just type :
    bbfreeze xxxx.py (ur main py file)

    http://pypi.python.org/pypi/bbfreeze/0.96.5

    ReplyDelete
  5. same problem here with email modules and py2exe

    i will try bbfreeze and update here

    ReplyDelete