[英]_tkinter.TclError: couldn't read file "C:\Users\{username}\AppData\Local\Temp\_MEI45522\sv_ttk\sv.tcl": no such file or directory
I have used Sun Valley Ttk Theme for my project (.py).我为我的项目 (.py) 使用了Sun Valley Ttk 主题。 It works on IDE (Thonny) but doesn't work when I converted the.py file to.exe.
它适用于 IDE (Thonny),但当我将 .py 文件转换为 .exe 时不起作用。
I got this error for the line: sv_ttk.set_theme("light")
:我收到以下行的错误:
sv_ttk.set_theme("light")
:
_tkinter.TclError: couldn't read file "C:\Users\{username}\AppData\Local\Temp\_MEI45522\sv_ttk\sv.tcl": no such file or directory.
Obviously this directory doesn't exist but why should it?显然这个目录不存在,但为什么要存在呢? What should I do?
我应该怎么办?
Theme folder, .py and.exe are in the same directory.主题文件夹,.py和.exe在同一个目录下。
Besides I used另外我用过
-add-data
to add theme folders as additional while converting to.exe.在转换为 .exe 时将主题文件夹添加为附加文件夹。
You need to include sv_ttk
module into the executable by using --collect-data
option of PyInstaller
:您需要使用 PyInstaller 的
PyInstaller
--collect-data
选项将sv_ttk
模块包含到可执行文件中:
pyinstaller --onefile --collect-data sv_ttk project.py
Assume project.py
is the main python script.假设
project.py
是主要的 python 脚本。
I had the same problem as you and this is my solution.我和你有同样的问题,这是我的解决方案。 I think it's more like a tricks
我觉得这更像是一个技巧
my case: C:\Users\PC-Name\AppData\Local\Programs\Python\Python310我的情况:C:\Users\PC-Name\AppData\Local\Programs\Python\Python310
tcl
-> tk8.6
and put your custom.tcl file here (Ex: sprites_light.tcl)tcl
-> tk8.6
并将您的 custom.tcl 文件放在这里(例如:sprites_light.tcl)pyinstaller Main.exe
pyinstaller Main.exe
执行你的程序dist
-> <your-exe-file-name>
-> tk
And find your tcl file.dist
-> <your-exe-file-name>
-> tk
并找到你的 tcl 文件。 If it's there then you've made it Goodluck, I hope it helpful!!祝你好运,希望对你有帮助!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.