PyInstaller exe在Tkinter脚本上返回错误

2024-04-28 09:49:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图通过Pyinstaller将一个使用标准python库和tkintergui构建的简单applet打包分发。PyInstaller编译(正确的术语?)很好,但是当我打开exe时,我得到了以下信息:

Traceback (most recent call last):
  File "site-packages/PyInstaller/loader/rthooks/pyi_rth__tkinter.py", line 28, in <module>
FileNotFoundError: Tcl data directory "/var/folders/sj/r0yyz8393ld2xrd_wf65bwxr0000gn/T/_MEIDeFnFy/tcl" not found.
[67821] Failed to execute script pyi_rth__tkinter
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

我试着调整我的编译设置,比如添加--hidden-import tkinter,但是没有用。在

脚本如下:

^{pr2}$

Tags: 信息most标准tkinterexehistory术语pyinstaller
1条回答
网友
1楼 · 发布于 2024-04-28 09:49:46

这似乎是在OSX上使用 onefile的已知问题

从python脚本所在的目录中尝试此操作

pyinstaller  onefile  add-binary='/System/Library/Frameworks/Tk.framework/Tk':'tk'  add-binary='/System/Library/Frameworks/Tcl.framework/Tcl':'tcl' your_script.py

这个解决方案是在公开发行的here中提出的

相关问题 更多 >