Skip to content

WinError2 - File cannot be found error when trying to run selective_search on Windows #23

@cfstiff

Description

@cfstiff

I'm trying to run the selective_search code. I was able to get demo.m to run, but cannot run the python version of the demo. This is the code that I have

   # Form the MATLAB script command that processes images and write to
    # temporary results file.
    f, output_filename = tempfile.mkstemp(suffix='.mat')
    os.close(f)
    fnames_cell = '{' + ','.join("'{}'".format(x) for x in image_fnames) + '}'
    command = "{}({}, '{}')".format(cmd, fnames_cell, output_filename)
    print(command)

# Execute command in MATLAB.
    mc = "C:\Program Files\MATLAB\R2016a\bin -nojvm -r \"try; {}; catch; exit; end; exit\"".format(command)
    pid = subprocess.Popen(
        shlex.split(mc), stdout=open('nul', 'w',) cwd=script_dirname)
    retcode = pid.wait()
    if retcode != 0:
        raise Exception("Matlab script did not exit successfully!")

And this is the error I'm getting:

Traceback (most recent call last):
File "selective_search.py", line 63, in <module>
    boxes = get_windows(image_filenames)
  File "selective_search.py", line 36, in get_windows
    shlex.split(mc), stdout=open('nul', 'w')) #, cwd=script_dirname)
  File "C:\Users\Coco Stiff\Anaconda3\lib\subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Coco Stiff\Anaconda3\lib\subprocess.py", line 1224, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

I've already added my matlab path, which I found by appending \bin to the result of matlabroot, and swapped \dev\null to nul. Is there something else I'm missing here? I'm on windows, which I think is causing the problems (I had previously managed to get this code working on mac).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions