简体   繁体   中英

Running Executable made with cx_Freeze giving traceback error

Here is my setup.py file for cx_Freeze

import sys
from cx_Freeze import setup, Executable
import os

os.environ['TCL_LIBRARY'] = r"C:\Users\Admin\AppData\Local\Programs\Python\Python35-32\tcl\tcl8.6"
os.environ['TK_LIBRARY'] = r"C:\Users\Admin\AppData\Local\Programs\Python\Python35-32\tcl\tk8.6"

build_exe_options = {"packages":["os"], "includes" : ["tkinter"]}

base = None

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

setup(name='APS West Email Generator',
  version='1.0',
  description='Auto generates Alarm notification emails. And maybe more in the future.',
  options = {"build_exe": build_exe_options},
  executables = [Executable("Tool_EmailGenerator.py", base=base)])

The executable is made with no errors. But when I try to run it I get the following window:

title: cx_Freeze: Python error in main script

contents: Traceback(most recent call last): file "c:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python35-32\\lib\\site-packages\\cx_Freeze\\initscripts__startup__.py",line12,in import (name+ " init ") file "c:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python35-32\\lib\\site-packages\\cx_Freeze\\initscripts\\Console.py",line 21, in scriptModule= import (moduleName) File "Tool_EmailGenerator.py", line 2, in File "c:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python35-32\\lib\\tkinter__init__.py", line 35, in import_tkinter #if this fails your python may not be configured for Tk ImportError: DLL load failed: The specified module could not be found.

tkinter works when I run the py file pre-cx_Freeze. I've searched the internet and tried various suggestions. nothings worked so far. I'm not sure whats causing this.

managed to fix this issue. Instead of doing: "includes" : ["tkinter"], I added tkinter to the packages. so: "packages":["os", "tkinter"] that seemed to work

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