【问题标题】:Using cx_Freeze to create executable (cannot import _tkinter, DLL load failed)使用 cx_Freeze 创建可执行文件(无法导入 _tkinter,DLL 加载失败)
【发布时间】:2017-07-08 15:37:27
【问题描述】:

我正在尝试使用 cx_Freeze 从我的 Python 项目创建一个可执行文件,但一直遇到此错误:

这是我的 setup.py:

import cx_Freeze
import os, sys

os.environ['TCL_LIBRARY'] = "D:\\Code\\Python\\3.5.2\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "D:\\Code\\Python\\3.5.2\\tcl\\tk8.6"

base = None
if sys.platform == "win32":
    base = "Win32GUI"

executables = [cx_Freeze.Executable("Main.pyw", base=base)]
includes      = ["tkinter"]
include_files = [r"D:\Code\Python\3.5.2\tcl\DLLs\tcl86t.dll", \
                 r"D:\Code\Python\3.5.2\tcl\DLLs\tk86t.dll"]

cx_Freeze.setup(
    name="Test", 
    version = "1.0",
    options={"Test.exe": {"packages":["pygame", "numpy"], "includes": includes, "include_files": include_files}}, 
    executables = executables)

我尝试将tkinter 放在“包”列表中,但仍然出现同样的错误。我还检查了其他 StackOverflow 帖子并将他们的部分setup.py 代码用于我的,但没有任何效果。我不能使用PyInstaller,因为它不支持pygame,而py2exe 不支持Python 3.5。任何帮助将不胜感激。

【问题讨论】:

  • 等到 cx_freeze 得到更新。目前放弃的项目

标签: python build cx-freeze


【解决方案1】:

将文件(tcl86t.dll、tk86t.dll)复制并粘贴到 exe.win 中。 它对我有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多