也许您可以尝试使用 cx_Freeze 包在 Windows 中构建您的应用程序(注意:如果您的 PC 是 64 位,则应用程序将采用该架构,如果是 x86 或 32 位,则应用程序将采用 32 位)
运行 cmd 并输入这个
pip install cx_Freeze
然后在同一目录中创建一个名为 setup.py 的文件并添加以下代码:
import cx_Freeze
import sys
import os
os.environ['TCL_LIBRARY'] = "C:\\Program Files\\Python27\\tcl\\tcl8.6" #you need to ubicate the library where tcl\tcl8.6 is
os.environ['TK_LIBRARY'] = "C:\\Program Files\\Python27\\tcl\\tk8.6" #you need to ubicate the library where tcl\tk8.6 is
base = None
if sys.platform == 'win32':
base = "Win32GUI"
executables = [cx_Freeze.Executable("name_of_your_app.py", base=base, icon="icon_of_your_app.ico")]
cx_Freeze.setup(
name = "Vtext",
options = {"build_exe": {"packages":["tkinter"], "include_files":["icon_of_your_app.ico", "maybe_some_img_that_your_app_is_using.gif", "another_img.gif"]}},
version = "1.0",
description = "name_of_your_app",
executables = executables
)"""
稍后打开一个 cmd 并更改您的应用所在的目录,例如:
C:\Users\Myname> cd C:\Users\Myname\MyTkinterApp
然后,输入:
python setup.py build
一切正常,您的应用程序即将构建
观看此视频了解更多信息:https://www.youtube.com/watch?v=HosXxXE24hA&t=0s&index=29&list=PLQVvvaa0QuDclKx-QpC9wntnURXVJqLyk