Differences between revisions 1 and 2
Revision 1 as of 2011-01-06 18:01:24
Size: 1218
Editor: techtonik
Revision 2 as of 2011-01-06 18:24:22
Size: 1228
Editor: techtonik
Comment: syntax highlight
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:

If your programs alters Python import mechanism somehow (like many applications with plugins and extensions) you may run into problems with py2exe. This page is dedicated to explain the reasons for these problems and how to solve them. If you have an experience to share, please add your story here.

Check that zipextimporter works on your system

zipextimporter is the starting component of py2exe that may cause problems. To debug it you will need _memimporter.pyd binary module. These modules can be found in binary py2exe distributions for your Python version (I unpack .exe distribution with 7Zip). zipextimporter contains the following script to help with debugging using standard _socket.pyd module. Wrap _socket.pyd from your Python version into lib.zip and use the script to see that zipextimporter works ok.

   1 import zipextimporter
   2 zipextimporter.install()
   4 import sys
   5 sys.path.insert(0, "lib.zip")
   7 import _socket
   8 print _socket
   9 # <module '_socket' from 'lib.zip\_socket.pyd'>
  10 print _socket.__file__
  11 # 'lib.zip\\_socket.pyd'
  12 print _socket.__loader__
  13 # <ZipExtensionImporter object 'lib.zip'>
  14 # Reloading also works correctly:
  15 print _socket is reload(_socket)
  16 # True

TroubleshootingImportErrors (last edited 2011-01-07 13:32:23 by techtonik)