2017-06-04 145 views
0

我编写了一个基本程序来跟踪客户名称,车辆,里程和日期,并且还有一个供用户选择查看的选项我用乌龟模块绘制的公司徽标。然后,我用cx_freeze冻结它作为一个可执行文件,并且所有东西都冻结了,包含所有必要文件和文件夹以及可执行文件的构建文件被创建,但是当我运行.exe文件时,我无法选择我的选项来查看公司商标。我不断地得到这个错误在CMD运行时:cx_Freeze导入错误:DLL加载失败:找不到指定的模块

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

回答

0

的图标是什么,你需要做的就是在你的setup.py,操作系统下运行.environ部分设置base等于none(base = None),然后在可执行文件变量中,在您放入OilExchange.py后,您需要输入一个逗号,例如base等于base(base = base),再放一个逗号,写入图标并将其设置为等于您的图标目录。这是我的例子executables = [Executable("texteditor.py", base=base, icon="books_logo.ico")]

-1

这里澄清一个更丰满的版本

from cx_Freeze import setup, Executable 
import sys 
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' 

# Dependencies are automatically detected, but it might need fine tuning. 
#build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]} 

base = None 
if sys.platform == 'win32': 
    base = 'Win32GUI' 
setup(
    name = "VBtEditor", 
    options = {"build_exe": {"packages":["tkinter", "os", "cx_Freeze"], "include_files": ["books_logo.ico"]}}, 
    version = "0.01", 
    description = "Professional text editor part of the VIRTUAL BUREAU", 
    executables = [Executable("texteditor.py", base=base, icon="books_logo.ico")] 
+0

你应该添加到您原来的答案,而不是发布一个新的 – Phydeaux

相关问题