[英]file not found error when running python script through tkinter .exe application No Such file or Directory
I have created my python script and linked in tkinter UI both.py files are running fine when i ran it visual studio code.我已经创建了我的 python 脚本并链接到 tkinter UI both.py 文件在我运行 visual studio 代码时运行良好。 But I have converted tkinter UI.py file to.exe file to run my python script in executable file.
但是我已经将 tkinter UI.py 文件转换为 .exe 文件以在可执行文件中运行我的 python 脚本。 I have successfuly converted the executable file.
我已经成功转换了可执行文件。 But when i run through the executable file(Application) No Such file in directory error coming
但是当我运行可执行文件(应用程序)时,目录中没有这样的文件错误来了
'c:\users\username\appdate\local\temp_MEI16402\myprogram.py' no such file or directory 'c:\users\username\appdate\local\temp_MEI16402\myprogram.py' 没有那个文件或目录
This is temp location这是临时位置
But i have my UI.py,myprogram.py in same location但是我的 UI.py,myprogram.py 在同一个位置
how to solve this error.如何解决这个错误。 Please help.
请帮忙。
To import myprogram.py
into UI.py
you can do this:要将
myprogram.py
导入UI.py
,您可以这样做:
import myprogram.py
The when you build it into an.exe file with pyinstaller you can add the --onefile
option to build both scripts into one file.当您使用 pyinstaller 将它构建到一个 .exe 文件中时,您可以添加
--onefile
选项以将两个脚本构建到一个文件中。 Here's an example:这是一个例子:
pyinstaller --onefile UI.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.