【问题标题】:Pyinstaller - FileNotFound errorPyinstaller - FileNotFounderror
【发布时间】:2018-05-04 21:14:22
【问题描述】:

我创建了一个 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'

我猜它没有识别出可能是一个不寻常的模块(货币转换器)

有没有办法解决这个问题?

谢谢

【问题讨论】:

  • 尝试使用--add-binary 选项。类似Pyinstaller --add-binary <path to zip>;currency_converter --onefile RFOutputGraphs.py
  • 感谢您的回复。我试过: Pyinstaller --add-binary ;currency_converter --onefile RFOutputGraphs.py ....它说它找不到指定的路径。我看了看,它不在那里。嗯
  • 实际上不包括“”。您需要找到该 zip 文件的实际位置。错误消息中的路径是 Pyinstaller 期望找到它的位置,但它不存在。这就是你得到错误的原因。添加该选项会将 zip 文件从其实际位置(您必须在选项中指定)复制到 Pyinstaller 期望找到它的位置。
  • 嘿,今天早上又开始工作了,效果很好。谢谢你。如果您想让您的评论成为答案,我会将其标记为已接受:)

标签: python pyinstaller


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-07
    • 1970-01-01
    • 1970-01-01
    • 2021-06-26
    • 1970-01-01
    • 1970-01-01
    • 2016-10-19
    相关资源
    最近更新 更多