Skip to content Skip to sidebar Skip to footer

Creating .exe File With Cx_freeze For A Tkinter Interface

I have searched for this answer all around the place, but i can't find an answer. I have a python script (3.3) that has an interface with tkinter. I used cx_freeze to create an exe

Solution 1:

I'd make this a comment but I don't have the reputation yet...

Any warnings/errors from the compilation output/logs?

Anything when you run the executable at the command prompt?

Does your executable need libraries that cx_freeze isn't finding?

You'll likely need to specify additional options like included libraries... Tweaking the example in the cx_freeze documentation you can specify to include TKinter:

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"includes": ["tkinter"]}

# GUI applications require a different base on Windows (the default is for a# console application).
base = Noneif sys.platform == "win32":
    base = "Win32GUI"

setup(
    name = "simple_Tkinter",
    version = "0.1",
    description = "Sample cx_Freeze Tkinter script",
    options = {"build_exe": build_exe_options},
    executables = [Executable("the timer.py", base = base)])

setup(  name = "guifoo",
        version = "0.1",
        description = "My GUI application!",
        options = {"build_exe": build_exe_options},
        executables = [Executable("guifoo.py", base=base)])

I know I've had lots of fun issues getting py2exe to work with PySide/PyQt4, matplotlib, numpy, etc. Some modules, like matplotlib, even provide a method to list all the data files necessary to build/distribute an application (matplotlib.get_py2exe_datafiles()). Solutions for Enthought's TraitsUI utilize glob to grab the directories of files needed. My point is, because module imports can be dynamic, messy, or black-magical in some libraries, many of the build utilities are unable to locate all the required resources. Also, once your executable is working, if you find stuff in the distribution you know your application won't need, you might can exclude it with additional options, which helps trim bloat from your distribution. Hopefully TKinter won't be too hard to get working - it appears others on StackOverflow were successful.

I'm sorry I don't have a rock solid solution, but I'm trying to help where I can! Good luck!

Post a Comment for "Creating .exe File With Cx_freeze For A Tkinter Interface"