Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install oct2py on windows?

I want to install oct2py in python. I am using windows 8.1

I used the command easy_install oct2py and I installed octave with the standard exe file. Now according to the installation guide I should add the octave path.

setx PATH "%PATH%;<path-to-octave-bin-dir>

I did not understand this command. I tried to add the path where is the octave.exe file to the environmental variables.

But when I try to import oct2py I get an error.

>>> import oct2py


Please install GNU Octave and put it in your path

>>> 

Can anyone please explain me exactly how to set the path?
An example of the command that I should run on the terminal would be very useful. Thanks

EDIT: I tried

setx PATH "%PATH%;C:\Software\Octave-3.6.4\bin"

but I received a strange message:

WARNINGS: The data being saved is truncated to 1024 characters
SUCCESS: Specified value was saved
like image 820
Donbeo Avatar asked Oct 21 '22 16:10

Donbeo


1 Answers

I'm not personally familiar with Octave, but it seems I've helped resolve this question. For others who may stumble upon this issue in the future, here's the process that led to the solution:


Given the error Please install GNU Octave and put it in your path, I searched the source code and found this from _utils.py:

try:
    cmd = 'octave -q --braindead'
    session = subprocess.Popen(cmd, shell=True,
                             stderr=subprocess.STDOUT,
                             stdin=subprocess.PIPE,
                             stdout=subprocess.PIPE,
                             preexec_fn=os.setsid)
except OSError:
    octave_path = glob('c:/Octave/*/bin/octave.exe')[0]
    if not os.path.exists(octave_path):
        msg = ('Please install Octave at "c:/Octave" '
                 '  or put it in your path:\n'
                 'setx PATH "%PATH%;<path-to-octave-bin-dir>"')
        raise Oct2PyError(msg)
    else:
        cmd = 'octave -q --braindead'
        session = subprocess.Popen(cmd, shell=True,
                             stderr=subprocess.STDOUT,
                             stdin=subprocess.PIPE,
                             stdout=subprocess.PIPE,
                             preexec_fn=os.setsid)
except OSError:
    raise Oct2PyError('Please put the Octave executable in your PATH')
return session

So this is raised when the command octave -q --braindead is attempted and fails


Next I asked OP whether the command ran properly on the command line, in order to isolate the problem. Running that, OP learned :MSYS shell available C:\Software\Octave-3.6.4\msys

Including that in the path is the solution

tl;dr

Path should not just be

C:\Software\Octave-[version]\bin

but rather

C:\Software\Octave-[version]\msys

like image 159
mhlester Avatar answered Oct 23 '22 11:10

mhlester