【发布时间】:2017-11-05 03:33:35
【问题描述】:
我编写了一个基本程序来跟踪客户姓名、车辆、里程和日期,它还有一个选项供用户选择查看我使用海龟模块绘制的公司徽标。然后我使用 cx_freeze 将其冻结为可执行文件,一切都冻结了,并创建了一个包含所有必要文件和文件夹的构建文件,并创建了一个可执行文件,但是当我运行 .exe 文件时,我无法选择查看公司的选项商标。在 CMD 中运行时,我继续收到此错误:
C:\Users\hdaug\Documents\Holden's Personal\PythonPrograms\CX\build\exe.win-amd64-3.6>OilChangeEx.exe
At Holden's Oil Change we use our custom built Python program to keep track of customer records and to display our company logo!!
Select and option from the menu!
1 Current Customers
2 New Customers
3 Company Logo
4 Quit
Select an option: 3
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
module.run()
File "C:\Program Files\Python36\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
exec(code, m.__dict__)
File "OilChangeEx.py", line 282, in <module>
File "OilChangeEx.py", line 56, in main
File "OilChangeEx.py", line 77, in commandChoice
File "OilChangeEx.py", line 176, in Turt
File "C:\Program Files\Python36\lib\turtle.py", line 107, in <module>
import tkinter as TK
File "C:\Program Files\Python36\lib\tkinter\__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: DLL load failed: The specified module could not be found.
错误的顶部是我的代码的实际运行,您可以看到4个选项;除#3 之外的所有这些工作。
我检查了 tkinter 文档和 cx_Freeze 文档,但找不到任何我做错的地方。这是我用来构建可执行文件的 setup.py 文件:
from cx_Freeze import setup, Executable
import os
os.environ['TCL_LIBRARY'] = r'C:\Program Files\Python36\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Program Files\Python36\tcl\tk8.6'
build_exe_options = {"includes": ["turtle","_tkinter"]}
setup(name='OilChange',
version='0.1',
description='OilChangeRecords',
options = {"build_exe": build_exe_options},
executables = [Executable('OilChangeEx.py')])
我的 build_exe 的“包含”中的 tkinter 模块,我尝试将其删除并拼写为 tkinter,我尝试将 tkinter 和 turtle 以及每个单独的模块放在“包”而不是“包含”中。我已经尝试了 cx_Freeze 文档中与我的情况相关的所有选项,但没有成功。
我发现了另一个与我的问题密切相关的问题:import _tkinter # If this fails your Python may not be configured for Tk 这个问题没有答案,我的问题有些不同。
我正在运行 Windows 10 操作系统和 Python 3.6.1 当从 Python IDLE 运行时,该脚本也可以工作
【问题讨论】:
标签: python python-3.x cmd cx-freeze python-3.6