11

I tried to package a Twisted program with py2exe, but once I run the exe file I built, I got a "No module named resource" error.

And I found the py2exe said:

The following modules appear to be missing ['FCNTL', 'OpenSSL', 'email.Generator', 'email.Iterators', 'email.Utils', 'pkg_resources', 'pywintypes', 'resource', 'win32api', 'win32con', 'win32event', 'win32file', 'win32pipe', 'win32process', 'win32security']

So how do I solve this problem?

Thanks.

Ferruccio
  • 98,941
  • 38
  • 226
  • 299
Fang-Pen Lin
  • 13,420
  • 15
  • 66
  • 96

2 Answers2

11

I've seen this before... py2exe, for some reason, is not detecting that these modules are needed inside the ZIP archive and is leaving them out.

You can explicitly specify modules to include on the py2exe command line:

python setup.py py2exe -p win32com -i twisted.web.resource

Something like that. Read up on the options and experiment.

teratorn
  • 1,489
  • 1
  • 11
  • 12
  • Put me on the right track, thanks. With newer versions, you need "cookielib" - which I had blacklisted previously to exclude it and save weight.. – totaam Apr 19 '16 at 15:13
0

Had same issue with email module. I got it working by explicitly including 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"]}})
K246
  • 1,077
  • 1
  • 8
  • 14