简体   繁体   中英

cx-Freeze Executable Won't Run on Another Computer

I wrote a program in Python and created an executable with cx-Freeze. I had to include tk and tcl libraries, as well as some images, in the setup.py for the executable to run correctly.

I linked these files to absolute paths on my computer, thinking that cx-freeze would copy these files over to the final executable folder so that it would become a part of its own package.

The program runs perfectly on my PC, but does not run on my colleague's PC.

Including the tcl and tk libraries as well as the images was a part of my troubleshooting process when the .exe wouldn't run. I have no idea of what to do next.

'''This is my setup.py file.'''

from cx_Freeze import setup, Executable
import sys
import os

includes = []

include_files = 
 [r"C:\Users\jchoujaa\AppData\Local\Programs\Python\Python37\DLLs\tcl86t.dll",
                 r"C:\Users\jchoujaa\AppData\Local\Programs\Python\Python37\DLLs\tk86t.dll",
                 r"C:\Users\jchoujaa\Desktop\Code\STARx App\Savvy Logger\Developer\Imaging\savron.png",
         r"C:\Users\jchoujaa\Desktop\Code\STARx App\Savvy Logger\Developer\Imaging\s-icon.ico",
         r"C:\Users\jchoujaa\Desktop\Code\STARx App\Savvy Logger\Developer\Imaging\STAR.png"]

os.environ['TCL_LIBRARY'] = r'C:\Users\jchoujaa\AppData\Local\Programs\Python\Python37\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\jchoujaa\AppData\Local\Programs\Python\Python37\tcl\tk8.6'

base = 'Win32GUI' if sys.platform == 'win32' else None

setup(name = "SavvyLogger",
        version = "1.0",
        description = "Logger Interpreter",
        options={"build_exe": {"includes": includes, "include_files": include_files, 'packages': ['pandas', 'numpy']}},
        executables = [Executable("SavvyLogger.py", base=base)])

This is the error my colleague receives when attempting to open my executable: enter image description here

Henry Yik's suggestion in the comments worked.

The problem was that I had set the path of the images used by tkinter to a folder located on my desktop.

Henry suggested I place the image files in the same folder as my .py script and remove the path names from the image variables.

This worked!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM