简体   繁体   English

python PyInstaller创建的可执行文件无法运行exe错误:找不到Temp \\\\ _ MEI175682(数据文件)

[英]python PyInstaller created executable failed to run the exe Error: cannot find Temp\\_MEI175682 (data file)

Using PyInstaller created an exe for my script and while running the exe it throws the following error where as if i run the .py file no issues found. 使用PyInstaller为我的脚本创建了一个exe,并在运行exe时抛出以下错误,好像我运行.py文件没有发现问题。

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\\\Users\\\\my_username\\\\AppData\\\\Local\\\\Temp\\\\_MEI175682\\\\resources\\\\template.json' [13396] Failed to execute script my_script

I've supplied all the proper flags for the data to be included by PyInstaller and the creation of the exe passed successfully. 我已经为PyInstaller包含的数据提供了所有正确的标志,并成功传递了exe的创建。

I have used --add-data flag and I have used data field in the spec file. 我使用了--add-data标志,我在spec文件中使用了data字段。

[Edit this line and add exact command you have given for creating exe] [编辑此行并添加您为创建exe所提供的确切命令]

Did deepdive in the error given directory path where no such directory or file exist. 在给定目录路径的错误中深入了解了没有这样的目录或文件的情况。 Could not locate Temp\\_MEI175682 无法找到Temp \\ _MEI175682

'C:\\Users\\my_username\\AppData\\Local\\Temp\\_MEI175682\\resources\\template.json'

The pyinstaller is intalled in .\\scripts\\ directory ;why pyinstaller is looking the .json file in the above directory where the file does not exist. pyinstaller安装在。\\ scripts \\目录中;为什么pyinstaller在上面目录中查找文件不存在的.json文件。

Also the file(template.json') is there in the .\\scripts\\template.json directory. 文件(template.json')也在。\\ scripts \\ template.json目录中。

To solve this issue what is the best way ? 要解决这个问题,最好的方法是什么? 1.Should something be added in the environment variable to resolve this? 1.应该在环境变量中添加一些东西来解决这个问题吗? 2.Should i create single file .exe by running the script from .\\scripts\\pyinstaller folder only ? 2.我应该通过从。\\ scripts \\ pyinstaller文件夹运行脚本来创建单个文件.exe吗? 3. Supplying any details to .spec file or adding certain details to .spec file after pyinstaller creating it would help solving this problem? 3.在pyinstaller创建它之后,向.spec文件提供任何细节或向.spec文件添加某些细节将有助于解决这个问题?

Any help that would solve the problem with details is much appreciated.Thanks in advance. 任何帮助解决问题的细节都非常感谢。谢谢。 Thanks in advance. 提前致谢。

This will be the easy and clean solution,Check and like and vote. 这将是简单而干净的解决方案,检查和喜欢并投票。

When you're encountering following error. 当您遇到以下错误时。

IOError: [Errno 2] No such file or directory: 'C:\\Users\\username\\AppData\\Local\\Temp\\_MEI502322\\resources\\template.json'

This solution tested under Python 2.7.10 and Pyinstaller 3.0. 此解决方案在Python 2.7.10和Pyinstaller 3.0下测试。

Put this file to your script folder. 将此文件放入脚本文件夹。 where your .py script available example 123.py 您的.py脚本可用示例123.py

Add this hook to your distribution it means add this in below in new file, example xyx.py and keep this file where the 123.py file available 将此挂钩添加到您的发行版中它意味着在下面的新文件中添加它,例如xyx.py并将此文件保存在123.py文件可用的位置

from PyInstaller.utils.hooks import collect_data_files

#Instruct pyinstaller to collect data files from resources package.
datas = collect_data_files('resources')

since this is the error C:\\Users\\my_username\\AppData\\Local\\Temp\\_MEI175682\\resources\\template.json " resources " is the package where from you have to take the data file. 因为这是错误C:\\ Users \\ my_username \\ AppData \\ Local \\ Temp \\ _MEI175682 \\ resources \\ template.json“ resources ”是您必须从中获取数据文件的包。

Now run the following in command window from your 123.py folder 现在从123.py文件夹中的命令窗口中运行以下命令

pyinstaller --onefile --additional-hooks-dir=. pyinstaller --onefile --additional-hooks-dir =。 123.py 123.py

exe will be created run the exe and check it is taking the data file. exe将创建运行exe并检查它是否正在获取数据文件。

thanks to Panda1100 感谢Panda1100

暂无
暂无

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

相关问题 */_MEI*/VCRUNTIME140.dll 不是为在 windows 上运行而设计的,或者在尝试运行由 pyinstaller 创建的 run.exe 时包含错误 - */_MEI*/VCRUNTIME140.dll is either not designed to run on windows or it contains as error when trying to run .exe created by pyinstaller 没有这样的文件或目录:使用 pyinstaller 将文件从 .py 编译为 .exe 后出现“Temp\\\\_MEI79882\\\\currency_converter\\\\eurofxref-hist.zip”错误 - No such file or directory : 'Temp\\_MEI79882\\currency_converter\\eurofxref-hist.zip' error after compiling file from .py to .exe with pyinstaller 尝试运行 pyinstaller 创建的 .exe 文件时“执行脚本失败” - “Failed to execute script” when trying to run .exe file created by pyinstaller 无法运行 pyinstaller 创建的 exe 文件,显示错误“google-api-python-client was not found” - Unable to run exe file created by pyinstaller, showing error "google-api-python-client was not found" 用PyInstaller创建的Python可执行文件无法运行 - Python executable created with PyInstaller doesn't run 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' 用pyinstaller创建的exe无法执行 - exe created with pyinstaller failed to execute 使用 pyinstaller 创建的 Python 可执行文件将不再与依赖包一起运行 - Python executable created using pyinstaller will no longer run with dependant packages Pyinstaller - Python exe 运行时显示错误“无法执行脚本 pyi_rth_nltk” - Pyinstaller - Python exe when run shows error “Failed to execute script pyi_rth_nltk” 在 C# 控制台应用程序中运行 Python EXE(在 PyInstaller 中创建) - Run a Python EXE (created in PyInstaller) in C# Console Application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM