简体   繁体   English

_tkinter.TclError:无法读取文件“C:\Users\{username}\AppData\Local\Temp\_MEI45522\sv_ttk\sv.tcl”:没有这样的文件或目录

[英]_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我觉得这更像是一个技巧

  1. Find your Python Directory where you save it in your computer在计算机中找到保存它的 Python 目录

my case: C:\Users\PC-Name\AppData\Local\Programs\Python\Python310我的情况:C:\Users\PC-Name\AppData\Local\Programs\Python\Python310

  1. Go to Folder tcl -> tk8.6 and put your custom.tcl file here (Ex: sprites_light.tcl)转到文件夹tcl -> tk8.6并将您的 custom.tcl 文件放在这里(例如:sprites_light.tcl)
  2. Execute your programs by pyinstaller Main.exe通过pyinstaller Main.exe执行你的程序
  3. When Done, Go to your Program Folder.完成后,转到您的程序文件夹。 There is a new folder created.已创建一个新文件夹。 Go 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如果它在那里那么你就成功了
  4. Finally, because it will need some *.png files to run well, so you will also copy the folder containing the png to the above folder (inside tk folder)最后,因为它需要一些 *.png 文件才能正常运行,所以你也将包含 png 的文件夹复制到上面的文件夹(在 tk 文件夹内)

Goodluck, I hope it helpful!!祝你好运,希望对你有帮助!!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 sv_ttk 和 pyinstaller 的问题 - Problems with sv_ttk and pyinstaller Pyinstaller Matplotlib [Errno 2] 没有这样的文件或目录:'C:\\Users\\Tobi\\AppData\\Local\\Temp\\_MEI142562\\matplotlib\\mpl-data\\matplotlibrc' - Pyinstaller Matplotlib [Errno 2] No such file or directory: 'C:\\Users\\Tobi\\AppData\\Local\\Temp\\_MEI142562\\matplotlib\\mpl-data\\matplotlibrc' tkinter.TclError:无法识别图像文件中的数据 - tkinter.TclError: couldn't recognize data in image file _tkinter.TclError:无法识别图像文件中的数据 - _tkinter.TclError: couldn't recognize data in image file 如何修复“_tkinter.TclError:无法打开”Island1.png“:没有这样的文件或目录”错误? - How to fix “_tkinter.TclError: couldn't open ”Island1.png“: no such file or directory” error? 我该如何解决错误_tkinter.TclError: couldn't open "sample.png": no such file or directory - How should I solve the error _tkinter.TclError: couldn't open "sample.png": no such file or directory _tkinter.TclError:无法打开“download.gif”:没有这样的文件或目录 - _tkinter.TclError: couldn't open "download.gif": no such file or directory _tkinter.TclError:使用乌龟图形时无法识别图像文件“ background.png”中的数据 - _tkinter.TclError: couldn't recognize data in image file “background.png” when using turtle graphics _tkinter.TclError: 无法打开 [暂停] - _tkinter.TclError: couldn't open [on hold] _tkinter.TclError:无法连接以显示“:0” - _tkinter.TclError: couldn't connect to display “:0”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM