[英]Running Executable made with cx_Freeze giving traceback error
這是我用於 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)])
可執行文件沒有錯誤。 但是當我嘗試運行它時,我得到以下窗口:
標題:cx_Freeze:主腳本中的 Python 錯誤
內容:回溯(最近一次調用最后一次):文件“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 加載失敗:找不到指定的模塊。
當我運行 py 文件 pre-cx_Freeze 時,tkinter 工作。 我在互聯網上搜索並嘗試了各種建議。 到目前為止什么都沒有。 我不確定是什么原因造成的。
設法解決了這個問題。 我沒有做:“包括”:[“tkinter”],而是將 tkinter 添加到包中。 所以:"packages":["os", "tkinter"] 似乎有效
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.