CX_FREEZE无法导入easygui tkinter mo

问题描述 投票:0回答:1

我正在尝试使用python3.7.6 cx_freeze创建Windows可执行文件(.exe)。我已从以下代码中删除了用户名和python脚本名称。

#!/usr/bin/env python3

import sys, os
from cx_Freeze import setup, Executable


PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ["TCL_LIBRARY"] = os.path.join(PYTHON_INSTALL_DIR, r"tcl", r"tcl8.6")
os.environ["TK_LIBRARY"] = os.path.join(PYTHON_INSTALL_DIR, r"tcl", r"tk8.6")

#includes = []
include_files = [r'C:\Users\<username>\AppData\Local\Programs\Python\Python37\DLLs\tcl86t.dll', 
r'C:\Users\<username>\AppData\Local\Programs\Python\Python37\DLLs\tk86t.dll']

build_options = {"packages": ["os","pandas","numpy","openpyxl","re","sys","easygui","pyexcel", 
"string", "utils","tkinter", 
r'C:\\Users\\<username>\\AppData\\Local\\Programs\\Python\\Python37\\lib\\tkinter'],"includes": 
[r'C:\\Users\\<username>\\AppData\\Local\\Programs\\Python\\Python37\\lib\\tkinter'], 'include_files': 
include_files}

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

setup(name="Extract from <script_name>",version="1.0",options ={'build_exe': 
build_options},description="Extracts information from <script_name>",executables= 
[Executable("<script_name>", base = base)])

构建后,系统提示我这些错误:

enter image description here

setup.py脚本基于:

cx_freeze Tkinter 'Module not Found'

When using cx_Freeze and tkinter I get: "DLL load failed: The specified module could not be found." (Python 3.5.3)

How to include tkinter when using cx_freeze to convert script to .exe?

Using EasyGui With Cx_Freeze

我已经尝试过在包含/包选项中同时指定/不指定模块,提供tkinter .dll文件和tkinter绝对包路径的方式进行构建。

我还检查了cx_freeze文档:

https://cx-freeze.readthedocs.io/en/latest/index.html

在常见问题中,它提到以下内容:

“检测到代码导入的模块,但是如果它们是动态加载的(例如,通过插件系统加载,则必须告知cx_Freeze关于它们的模块。”

如果是这种情况,并且是问题的原因,我将如何识别动态加载的软件包?

解决该问题的任何帮助将不胜感激。

再次感谢,

enzsio

python-3.x tkinter cx-freeze easygui
1个回答
0
投票

只是偶然偶然发现了答案。使用以下命令进行构建后:

python3 setup.py build

我在构建中的lib文件夹中闲逛。 tkinter库(目录)被命名为Tkinter(容量为“ T”)。我将目录名称更改为“ tkinter”并运行了可执行文件。程序完美启动。

[我想对那些查看此主题并打算回答的人表示感谢。

再次感谢!enzsio

© www.soinside.com 2019 - 2024. All rights reserved.