Pyinstaller - FileNotFound 错误

Pyinstaller - FileNotFound error

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

Pyinstaller –-onefile RFOutputGraphs.py

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

我的错误是:

      FileNotFoundError: [Errno 2] no such file or directory:
     'C:\Users\Nicholas\AppData\Local\Temp\_MEI30362\currency_converter
     \eurofxref-hist.zip'

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

有办法解决这个问题吗?

谢谢

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

Pyinstaller --add-binary <path to zip>;currency_converter --onefile RFOutputGraphs.py 

这会将 zip 文件从其在您 PC 上的位置复制到 .exe 文件中,并安排在 .exe是 运行。看看 Using Pyinstaller.