Pyinstaller - FileNotFound 错误

Sco*_*tEU 4 python pyinstaller

我创建了一个 python 脚本,并使用以下命令将其转换为 .exe 文件:

\n\n
Pyinstaller \xe2\x80\x93-onefile RFOutputGraphs.py\n
Run Code Online (Sandbox Code Playgroud)\n\n

它可以工作,但是脚本中的一项作业失败了,尽管它在从 Python 运行时工作得很好。

\n\n

我的错误是:

\n\n
      FileNotFoundError: [Errno 2] no such file or directory:\n     'C:\\\\Users\\\\Nicholas\\\\AppData\\\\Local\\\\Temp\\\\_MEI30362\\\\currency_converter\n     \\\\eurofxref-hist.zip'\n
Run Code Online (Sandbox Code Playgroud)\n\n

我猜它没有识别出什么可能是不寻常的模块(currencyconverter)

\n\n

有办法解决这个问题吗?

\n\n

谢谢

\n

Joh*_*son 6

Pyinstaller您可以将 zip 文件包含在使用以下选项创建的 .exe 中--add-binary

Pyinstaller --add-binary <path to zip>;currency_converter --onefile RFOutputGraphs.py 
Run Code Online (Sandbox Code Playgroud)

currency_converter这会将 zip 文件从 PC 上的位置复制到 .exe 文件中,并在 .exe 运行时将其解压到文件夹(错误消息中提到的位置)中。看看使用 Pyinstaller