Search code examples
pythonpython-3.xcx-freeze

Python to EXE builds a nothing-doing file


I used cx_Freeze module to convert my Python applications to Windows.

I have a simple Python file norm.py :

print("Hi there !")

Another file makeup.py to convert the above into exe:

import sys
from cx_Freeze import setup, Executable

include_files = ['autorun.inf']
os_base = None

if sys.platform == "win32":
    os_base = "Win32GUI"

setup(name="puzzle",
        version="0.1",
        description="Very cool puzzle",
        options={'build_exe':{'include_files':include_files}},
        executables=[Executable("norm.py", base=os_base)])

I also have autorun.inf in the same folder. There are also no errors coming when I build this by running command:

python makeup.py build

It creates a build folder inside which there is norm.exe .When I run this exe through my terminal , it doesn't do anything.I am expecting it to print "Hi there!"

I am using Python 3.4 as some posts said that 3.5 has a problem with this module.


Solution

  • You are creating a GUI application using

    if sys.platform == "win32":
        os_base = "Win32GUI"
    

    You should remove this, in order to build a console application.