简体   繁体   English

通过 tkinter.exe 应用程序运行 python 脚本时找不到文件错误 没有这样的文件或目录

[英]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.

相关问题 通过python在运行shell脚本中找不到文件 - file not found in running shell script through python Python RPi - 从另一个脚本运行脚本时找不到文件 - Python RPi - File not found when running script from another script tkinter中的子进程,正在运行.exe文件 - Subprocess in tkinter, running .exe file 在循环目录时需要一些关于 Python 中 DBF“未找到文件”错误的帮助? - Need some assistance on a DBF "File not found" error in Python when looping through a directory? 使用 Python 多处理运行 a.exe 文件时出错 - Error when running a .exe file using Python multiprocessing 添加shebang会导致运行我的python脚本时出现此类文件或目录错误 - Adding a shebang causes No such file or directory error when running my python script 在终端中运行 python 脚本时出错:OSError: [Errno 2] No such file or directory - Error running python script in terminal: OSError: [Errno 2] No such file or directory 仅在运行脚本文件时找不到Python 3.4 MySQL Connector - Python 3.4 MySQL Connector Not Found Only When Running a Script File 将 tkinter 脚本转换为 .exe 文件后,尝试执行时出现错误:ModuleNotFoundError: No module named 'numpy' - After converting tkinter script into .exe-file, when try executing, there is error: ModuleNotFoundError: No module named 'numpy' 在 Ubuntu 上运行 Python bot(找不到文件或目录?) - Running Python bot on Ubuntu (file or directory not found?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM