Skip to content Skip to sidebar Skip to footer

How To Include Tkinter When Using Cx_freeze To Convert Script To .exe?

I am using cx_freeze to transfer a python file to a exe. the problem is when i exclude tkinter in the setup.py, i can generate the exe file successfully, but when execute the exe f

Solution 1:

You have to make two modifications to your setup.py to get things working:

  1. Set TCL-LIBRARY and TK_LIBRARY environment variables. (You already did this)

  2. Add the tcl86t.dll and tk86t.dll to your include_files parameter

So the setup.py should look something like this:

import os
from cx_Freeze import setup, Executable

os.environ['TCL_LIBRARY'] = 'c:/python36/tcl/tcl8.6'
os.environ['TK_LIBRARY'] = 'c:/python36/tcl/tk8.6'# Dependencies are automatically detected, but it might need# fine tuning.
buildOptions = dict(
    packages = [],
    excludes = [],
    include_files=['c:/python36/DLLs/tcl86t.dll', 'c:/python36/DLLs/tk86t.dll']
)

import sys
base = 'Win32GUI'if sys.platform=='win32'elseNone

executables = [
    Executable('editor.py', base=base)
]

setup(name='editor',
      version = '1.0',
      description = '',
      options = dict(build_exe = buildOptions),
      executables = executables)

Post a Comment for "How To Include Tkinter When Using Cx_freeze To Convert Script To .exe?"