pyinstaller生成带有oct2py导入的可执行错误

时间:2019-03-11 19:17:27

标签: python pyinstaller oct2py

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

1 个答案:

答案 0 :(得分:0)

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

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

import oct2py
os.makedirs(temp_folder, exist_ok=True)
octave = oct2py.Oct2Py(temp_dir=temp_folder)