2

我正在尝试制作一个使用 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。

4

1 回答 1

0

有同样的问题并从这里得到答案: https ://github.com/blink1073/oct2py/issues/144

该解决方案似乎将临时文件夹作为参数传递给 oct2py。

import oct2py
os.makedirs(temp_folder, exist_ok=True)
octave = oct2py.Oct2Py(temp_dir=temp_folder)
于 2020-08-14T03:49:03.050 回答