Search code examples
pythonpython-3.4cx-freeze

Fatal Python error when trying to run an executable Python script


I have a Python script that I have turned into an executable using cx-freeze-4.3.4.win32-py3.4. I have Python 3.4 installed on a Windows 7 64-bit machine.

Here is my simple setup.py file:

from cx_Freeze import setup, Executable

setup( name = "myfilename" , 
       version = "0.1" , 
       description = "This is my file" , 
       executables = [Executable("myfilename.py")] , )

I ran python setup.py build from command prompt in the C:\Python34 folder with both the script I was trying to convert and the setup.py file. This created another folder called build within was another folder called exe.win32-3.4. In that folder I found my executable file, a bunch of .pyd files, a single .dll file, and a zipped archive called library of a bunch of .pyc files.

If I run the executable from within the exe.win32-3.4 with the library zip archive it executes fine. However, without the library archive of .pyc files (basically if I try just to run the .exe by itself, which is what I am supposed to be able to do) the executable throws out this error:

Fatal Python error: cannot get zipimpirter instance

Current thread 0x000001b48 (most recet call first):

I did some preliminary searching around the web for potential resolutions to the issue but could not find anything substantial. If anyone knows how to troubleshoot this issue that would be much appreciated.


Solution

  • From the docs:

    Single-file executables

    cx_Freeze does not support building a single file exe, where all of the libraries for your application are embedded in one executable file.

    For a single-file solution using py2exe and others, see this question.

    In 3.5 there is also the new zipapp module, although the basic functionality has been around for a while.