After creating python exe file with cx_freeze the file doesn't do anything

Snake P picture Snake P · Oct 9, 2012 · Viewed 14.7k times · Source

I recently created used cx_freeze to create a python 3.2.2 exe file. When I tried to run the exe file nothing happened.

Here is the code for my test.py file:

print("hello world")

for i in range(5):
    print(i)

Here is the code for my testSetup.py file:

from cx_Freeze import setup, Executable

exe = Executable(
   script="test.py",
   base="Win32GUI",
   targetName="Test.exe"
   )


setup(
    name = "Test",
    version = "0.1",
    description = "I wish programming was this easy",
    executables = [exe])

The build directory that cx_freeze made has a folder called exe.win32-3.2 which has the files:

bz2.pyd
library.zip
python32.dll
Test.exe
unicodedata.pyd

Answer

Chrugel picture Chrugel · Apr 21, 2013

My suggestion:

  1. set base = None (try it: maybe that's all you want? base = Win32GUI does "hide" the console - this is useful when you're building a GUI)

  2. In the same folder with your .exe make a batch-file (a text-file with .bat) calling your .exe:

this goes into your batch-file:

name-of-your-app.exe %1

PAUSE

You'll start your app by clicking the batch-file - it keeps the console open so you're able to reed the errors/output.