Search code examples
pythoncx-freeze

Python: cx_Freeze: Noting happend if I click the .exe


nothing happend when I double click the test.exe.....

But to start from the beginning, I create a Little python Programm which is in test.py:

test.py:

import tkinter 
top = tkinter.Tk()
top.mainloop()`

Then I use cx_Freeze to convert test.py to an exe: The following lines are in my Setup.py:

import sys
from cx_Freeze import setup, Executable
import os
build_exe_options = {"packages": ["tkinter"], "include_files":[r"C:\\Program
Files\\Python36\\tcl\\tcl8.6",
         r"C:\\Program Files\\Python36\\tcl\\tk8.6"]}
os.environ['TCL_LIBRARY'] = "C:\\Program Files\\Python36\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Program Files\\Python36\\tcl\\tk8.6" 
base = None
if sys.platform == "win32":
    base = "Win32GUI"    `      
setup(  name = "stest",
    version = "1.0",description = "hello",
    options = {"build_exe": build_exe_options},
    executables = [Executable("test.py", base='Win32GUI')])`

Then I open a cmd and type in the following " python setup.py build". No erros appears while Building.

But if I click the test.exe nothing happend.

Where is my mistake?


Solution

  • Do NOT install cx_freeze by "pip install cx_freeze", because an old Version will be installed,

    instead go to https://pypi.python.org/pypi/cx_Freeze and then download the right version.

    Use for example pip install cx_Freeze-6.0b1-cp36-cp36m-win_amd64.whl.

    Finally copy the file "tcl86t.dll" and "tk86t.dll" into the build folder