【发布时间】:2019-08-02 04:21:56
【问题描述】:
我正在尝试制作一个使用 oct2py 评估 .m 文件的 python 可执行文件。 python 脚本可以独立工作。我已经成功地使用 pyinstaller 制作了一个可执行文件(使用 --onefile,构建它时没有错误),但是当我运行这个可执行文件时,我收到以下错误并且可执行文件退出:
C:\Users\Jason\Desktop\Oct2Py test>readFolder.exe
error: '_pyeval' undefined near line 1 column 1
Traceback (most recent call last):
File "site-packages\scipy\io\matlab\mio.py", line 33, in _open_file
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/Jason/AppData/Local/Temp/tmpbn8aefsj/reader.mat'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "readFolder.py", line 8, in <module>
octave.eval('pkg load io')
File "site-packages\oct2py\core.py", line 484, in eval
File "site-packages\oct2py\core.py", line 369, in feval
File "site-packages\oct2py\core.py", line 565, in _feval
File "site-packages\oct2py\io.py", line 28, in read_file
File "site-packages\scipy\io\matlab\mio.py", line 141, in loadmat
File "site-packages\scipy\io\matlab\mio.py", line 64, in mat_reader_factory
File "site-packages\scipy\io\matlab\mio.py", line 39, in _open_file
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/Jason/AppData/Local/Temp/tmpbn8aefsj/reader.mat'
[1456] Failed to execute script readFolder
看来问题首先在于“mio.py”,但我无法弄清楚它在哪里寻找“reader.mat”。我认为“reader.mat”是 oct2py 创建的某种临时文件。
只是为了确保 python 脚本正确运行并正确评估整个 oct2py 引用的 .m 文件。
谢谢
python 3.7,pyinstaller 3.5 开发,oct2py 4.0.6。
【问题讨论】:
-
看起来 SciPy 找不到该文件 - 您是否尝试过使用 specfile 来查看是否可以明确声明需要它?否则有an excellent page in the documentation关于故障排除!
-
是的,阿里。特别是 mio.py 调用 _open_file 失败。现在,很明显 reader.mat 是一个临时文件,必须在执行时创建 - 所以我想我错过了其他东西,但我不知道是什么。一旦我知道我需要链接什么,我就可以尝试按照你的建议修改规范文件。
-
如果程序在运行时创建临时文件,不要使用'--onefile'标志。
-
谢谢 Hiadore,但恐怕没有用:
-
感谢@Hiadore,但恐怕这不起作用:'C:\Users\Jason\Desktop\Oct2Py test>dist\readFolder\readFolder.exe error: '_pyeval' undefined near line 1 column 1 .... FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/Jason/AppData/Local/Temp/tmpc17tnd51/reader.mat' 在处理上述异常过程中,又出现了一个异常: .......文件“site-packages\scipy\io\matlab\mio.py”,第 37 行,在 _open_file FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/Jason/AppData /Local/Temp/tmpc17tnd51/reader.mat' [11220] 无法执行脚本readFolder'
标签: python pyinstaller oct2py