简体   繁体   English

cx_Freeze导入错误:DLL加载失败:找不到指定的模块

[英]cx_Freeze Import Error: DLL load failed: The specified module could not be found

I wrote a basic program to keep track of customer names, vehicles, mileage, and date, and it also has an option for the user to choose to see a company logo that I drew using the turtle module. 我编写了一个基本程序来跟踪客户名称,车辆,里程和日期,它还提供了一个选项供用户选择查看我使用turtle模块绘制的公司徽标。 Then I used cx_freeze to freeze it as an executable, and everything froze and a build file with all the necessary files and folders and an executable was created, but when I run the .exe file I can't choose my option to view the company logo. 然后,我使用cx_freeze将其冻结为可执行文件,然后所有内容冻结,并创建了包含所有必需文件和文件夹以及可执行文件的构建文件,但是当我运行.exe文件时,无法选择查看公司的选项。商标。 I continue to get this error when running it in CMD: 在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.

The top part of the error is the actual running of my code and you can see the 4 options; 错误的顶部是我的代码的实际运行,您可以看到4个选项。 all of these work other than #3. 除#3以外,所有这些工作都可以。

I have checked in the tkinter documentation and the cx_Freeze documentation and cannot find anything that I am doing wrong. 我已经检查了tkinter文档和cx_Freeze文档,但找不到我做错的任何事情。 Here is my setup.py file that I am using to build my executable: 这是我用来构建可执行文件的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')])

The tkinter module in the "includes" for my build_exe, I have tried to remove and spell it just tkinter, I have tried to put both tkinter and turtle, and each individual module in "packages" instead of "includes". 我的build_exe的“包含”中的tkinter模块,我试图将其删除并拼写为tkinter,我试图将tkinter和turtle以及每个单独的模块都放入“包”中,而不是“ includes”中。 I have tried every option that relates to my situation in the cx_Freeze documentation with no luck. 我在cx_Freeze文档中尝试了所有与我的情况有关的选项,但没有走运。

I found another question that closely relates to mine: import _tkinter # If this fails your Python may not be configured for Tk There are no answers to this question and mine somewhat differs. 我发现了另一个与我的问题密切相关的问题: import _tkinter#如果失败,则可能没有为Tk配置Python 。该问题没有答案,我的情况有所不同。

I am running Windows 10 OS and Python 3.6.1 Also the script does work when ran from the Python IDLE 我正在运行Windows 10 OS和Python 3.6.1,并且从Python IDLE运行时,脚本也可以正常工作

for the icon what you will need to do is in your setup.py, under the os.environ part set base equal to none(base=None) and then in the executables variable, right after you put OilExchange.py you need to put a comma, say base equals base(base=base), put another comma, write icon and set it equal to your icon directory. 对于图标,您需要做的是在setup.py中,在os.environ部件下,将base设置为none(base = None),然后在可执行文件变量中,将OilExchange.py放进去。一个逗号,例如说base等于base(base = base),放另一个逗号,写图标,并将其设置为等于图标目录。 Here is my example executables = [Executable("texteditor.py", base=base, icon="books_logo.ico")] 这是我的示例executables = [Executable("texteditor.py", base=base, icon="books_logo.ico")]

here is a more fuller version for clarification 这是一个更完整的版本以供澄清

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")]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 cx_Freeze ImportError: DLL load failed while importing _ctypes: 找不到指定的模块 - cx_Freeze ImportError: DLL load failed failed while importing _ctypes: The specified module could not be found 当使用cx_Freeze和tkinter时,我得到:“DLL加载失败:找不到指定的模块。”(Python 3.5.3) - When using cx_Freeze and tkinter I get: “DLL load failed: The specified module could not be found.” (Python 3.5.3) Python 3.3.4 Cx_Freeze ImportError:DDL加载失败:找不到指定的模块 - Python 3.3.4 Cx_Freeze ImportError: DDL load failed: The specified module could not be found cx_freeze,导入错误:DLL加载失败(tkinter) - cx_freeze, import error: DLL load failed (tkinter) 导入错误:DLL 加载失败。 指定的模块无法找到 - Import Error: DLL load failed. The specified module could not be found Pyinstaller:导入错误:DLL 加载失败:找不到指定的模块 - Pyinstaller: Import Error: DLL load failed: The specified module could not be found Cx_Freeze DLL加载失败 - Cx_Freeze DLL load failed cx_freeze 错误:未找到模块 tkinter - cx_freeze Error: Module not found tkinter “import torch”给出错误“from torch._C import *, DLL load failed: The specified module could not be found” - "import torch" giving error "from torch._C import *, DLL load failed: The specified module could not be found" 使用cx_Freeze创建可执行文件(无法导入_tkinter,DLL加载失败) - Using cx_Freeze to create executable (cannot import _tkinter, DLL load failed)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM