[英]Running Executable made with cx_Freeze giving traceback error
Here is my setup.py file for cx_Freeze这是我用于 cx_Freeze 的 setup.py 文件
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标题:cx_Freeze:主脚本中的 Python 错误
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.内容:回溯(最近一次调用最后一次):文件“c:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python35-32\\lib\\site-packages\\cx_Freeze\\initscripts__startup__.py”,line12,in import (name+ " init ") 文件 "c:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python35-32\\lib\\site-packages\\cx_Freeze\\initscripts\\Console.py", line 21, in scriptModule= import (moduleName)文件“Tool_EmailGenerator.py”,第 2 行,在文件“c:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python35-32\\lib\\tkinter__init__.py”,第 35 行,在 import_tkinter #如果这失败了你的 python可能未为 Tk 配置导入错误:DLL 加载失败:找不到指定的模块。
tkinter works when I run the py file pre-cx_Freeze.当我运行 py 文件 pre-cx_Freeze 时,tkinter 工作。 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.
我没有做:“包括”:[“tkinter”],而是将 tkinter 添加到包中。 so: "packages":["os", "tkinter"] that seemed to work
所以:"packages":["os", "tkinter"] 似乎有效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.