5

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
Suever
  • 64,497
  • 14
  • 82
  • 101
Donbeo
  • 17,067
  • 37
  • 114
  • 188
  • What happens when you call `octave -q --braindead` on the command line? – mhlester Jan 21 '14 at 18:01
  • In my windows shell copy paste does not work. Maybe you are interested in the line :MSYS shell available C:\Software\Octave-3.6.4\msys ?? Should I use this as path? – Donbeo Jan 22 '14 at 16:14
  • Ok it works now. Thanks !! But how could I know that the correct directory was msys? – Donbeo Jan 22 '14 at 16:41

1 Answers1

3

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

Community
  • 1
  • 1
mhlester
  • 22,781
  • 10
  • 52
  • 75
  • today I rebooted the pc and the program does not work anymore. When I try octave -q --braindead i get: "octave is not recognized as an internal or external command, operable program or batch file" – Donbeo Jan 23 '14 at 10:58
  • I do not think that octave is in the path. The command works if I am in the octave directory – Donbeo Jan 24 '14 at 08:37
  • 1
    I do not know exactly how but know it is working. I have added the enviromental variables to the system path and not to the user path. I will check if it works during the next days – Donbeo Jan 24 '14 at 10:25