使用 Pyinstaller 制作 exe 文件时出现问题(使用 tkinter 和 Custom tkinter 制作的文件)

2024-05-04

我正在尝试使用 tkinter 和自定义 tkinter 制作一个用于数据输入的小型应用程序。代码在 python 中运行良好,我使用它制作了 exe 文件 pyinstaller --onefile --noconsole try45.py

但在运行 exe 文件时,它会给出标记为“脚本中未处理的异常”的错误。其详细信息附如下,

我还附上了错误的图像。它的前两行说 “由于未处理的异常,无法执行脚本‘try45’:[Errno 2]没有这样的文件或目录:‘C:\Users\Farzan Bashir\AppData\Local\Temp\_MEI127522\customtkinter\assets\themes\blue.json”

下一行的详细信息是,

回溯(最近一次调用最后一次):文件“try45.py”,第 2 行,在文件“”,第 1027 行,在 _find_and_load 文件“”,第 1006 行,位于 _find_and_load_unlocked 文件“”,第 688 行,位于load_unlocked 文件“PyInstaller\loader\pyimod03_importers.py”,第 495 行,在 exec_module 文件“customtkinter_init.py”,第 3 行,文件“”,第 1027 行,在 _find_and_load 文件“”,第 1006 行,在 _find_and_load_unlocked 文件“”,第 688 行,在 _load_unlocked 文件“PyInstaller\loader\pyimod03_importers.py”,第 495 行,在exec_module 文件“customtkinter\widgets\customtkinter_input_dialog.py”,第 4 行,在文件“”,第 1027 行中, _find_and_load 文件“”,第 1006 行,在 _find_and_load_unlocked 文件“”,第 688 行,在 _load_unlocked 文件“PyInstaller\loader\pyimod03_importers.py”,第 495 行,在 exec_module 文件“customtkinter\widgets\customtkinter_label.py”,第 4 行,在文件“”,第 1027 行,位于 _find_and_load 文件“”,第 1006 行,在 _find_and_load_unlocked 文件“”,第 688 行,在 _load_unlocked 文件“PyInstaller\loader\pyimod03_importers.py”,第 495 行,在 exec_module 文件“customtkinter\widgets\customtkinter_tk.py”,第 9 行,在文件“”,第 1027 行,位于 _find_and_load 文件“”,第 1006 行,位于 _find_and_load_unlocked 文件“”,第 688 行,在 _load_unlocked 文件“PyInstaller\loader\pyimod03_importers.py”,第 495 行,在 exec_module 文件“customtkinter\customtkinter_theme_manager.py”,第 83 行,在文件“customtkinter\customtkinter_theme_manager.py”,第 16 行,在 load_theme FileNotFoundError: [Errno 2] 没有这样的文件或目录: 'C:\Users\Farzan Bashir\AppData\Local\Temp\_MEI44122\customtkinter\assets\themes\blue.json'

请帮忙 !!!


遇到了同样的问题,将 site-packages 文件夹中的自定义 tkinter 文件夹数据添加到控制台命令中解决了它,在这里:

pyinstaller --noconfirm --onefile --windowed --add-data "C:\Users\(your pc name)\AppData\Local\Programs\Python\(your python version that has custom tkinter)\Lib\site-packages\customtkinter;customtkinter/"  "<Path to Python Script>"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Pyinstaller 制作 exe 文件时出现问题(使用 tkinter 和 Custom tkinter 制作的文件) 的相关文章