2

I am trying to make a python executable which uses oct2py to eval a .m file. The python script works just fine independently. I have been successful in using pyinstaller to make an executable (using --onefile, no errors in building it), but when I run this executable I get the following error and the executable quits:

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

It appears the issue is first with 'mio.py', but I cannot figure out where it's looking for 'reader.mat'. I think 'reader.mat' is some sort of temporary file created by oct2py.

Just to be sure the python script runs correctly and evaluate the whole oct2py referenced .m file correctly.

Thanks

python 3.7, pyinstaller 3.5 dev, oct2py 4.0.6.

DNR
  • 31
  • 4
  • It looks like SciPy can't find the file - have you tried playing with the [specfile](https://pyinstaller.readthedocs.io/en/stable/spec-files.html#using-spec-files) to see if you can explicitly declare that it's needed? Otherwise there's [an excellent page in the documentation](https://pyinstaller.readthedocs.io/en/v3.4/when-things-go-wrong.html) about troubleshooting! – Ari Cooper-Davis Mar 11 '19 at 19:22
  • Yes Ari. Specifically mio.py call _open_file is failing. Now, it's also clear that reader.mat is a temp file which must've been created on execution - so I think I'm missing something else but I don't know what. Once I know what I need to link in I can attempt to modify the spec file as you suggested. – DNR Mar 11 '19 at 23:46
  • 1
    If the program create temporary file on runtime, don't use '--onefile' flag. – Hiadore Mar 12 '19 at 04:41
  • Thanks Hiadore, but I'm afraid that did not work: – DNR Mar 13 '19 at 00:56
  • Thanks @Hiadore, but I'm afraid that did not work:'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' During handling of the above exception, another exception occurred: ....... File "site-packages\scipy\io\matlab\mio.py", line 37, in _open_file FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/Jason/AppData/Local/Temp/tmpc17tnd51/reader.mat' [11220] Failed to execute script readFolder' – DNR Mar 13 '19 at 01:02
  • have you by any means solved the problem? I have the same issue. – Klien Menard Apr 29 '20 at 12:58

1 Answers1

0

Had the same problem and got the answer from here: https://github.com/blink1073/oct2py/issues/144

The solution seems to be passing a temp folder as argument to oct2py.

import oct2py
os.makedirs(temp_folder, exist_ok=True)
octave = oct2py.Oct2Py(temp_dir=temp_folder)
  • Did not work for me. The issue is not the path, but that the file "reader.mat" is not in the temp folder. for some reason only the file "writer.mat" is in the temp folder – litmus Sep 01 '21 at 08:23