Search code examples
pythoninno-setupcx-freeze

After install cx_freeze cannot get zip importer


I use Inno Setup to install a Python application after building with distutils. The output of the build contains the *.pyd files in the top level directory, alongside the actual executable.

If I then run this application from the build directory it functions normally.

When I run it after an install, in which the setup script has moved *.pyd and *.dll into a subdirectory, it seems the application can no longer find these files. I get the following error:

cx_Freeze Fatal Error

cannot get zipimporter instance

I suspect it is because of moving the required module in the install. Is there any way I can move them into the path? Or tell the application where to look if frozen somehow?

I would be satisfied with moving the application executable into the libs folder and point a shortcut at it, but this seems sloppy and I really don't prefer it.

To be clear my build directory should look familiar.

build
  myapp.exe
  _bz2.pyd
  ...

After install I purposely end up with something like this.

Program Files\MyApp
  myapp.exe
  libs
    _bz2.pyd
    ...

Solution

  • All your pyd's, dll's and zips must be in the same folder as the exe at the moment. This has been on the feature list for cx_freeze, but is not yet implemented.

    See this post: http://sourceforge.net/p/cx-freeze/mailman/message/32075893/