8

So, I'm trying to use oct2py on Windows, like so:

from oct2py import octave

That's literally the only code I need to reproduce the error.

When I execute this, I get OSError: Octave Executable not found, please add to path or set"OCTAVE_EXECUTABLE" environment variable. However, I have already set OCTAVE_EXECUTABLE as a system variable, which points to "C:\Octave\Octave-4.4.1\bin\octave-cli-4.4.1.exe". Opening up the command line and running %OCTAVE_EXECUTABLE% gives me the Octave CLI, so I know it's right.

I've tried rebooting. I've also tried adding the Octave folder to my Path and removing OCTAVE_EXECUTABLE. Neither work.

EDIT: I've also tried using just octave-cli.exe, and I've tried doing print(os.environ['OCTAVE_EXECUTABLE']), which returns the expected path.

Any ideas here?

ChesuCR
  • 9,352
  • 5
  • 51
  • 114
John Chrysostom
  • 3,973
  • 1
  • 34
  • 50

5 Answers5

2

In spite of what you mention in your comment:

It appears that, somewhere along the line, octave.exe got replaced with octave-cli.exe. There is no longer an octave.exe distributed with the Octave package. Others have successfully pointed OCTAVE_EXECUTABLE at octave-cli.exe

Recently more people had a similar issue and the oct2py developers fixed it in the 5.0.0 version some hours ago. Actually they said:

Ah, I see what the issue is here. The convenience octave instance is created before you get a chance to set the executable property. Given that fact, I think the only right answer is to remove the executable argument in favor of using PATH or the OCTAVE_EXECUTABLE environment variable.

Anyway I had to adapt my code to make it work updating the environment variable OCTAVE_EXECUTABLE:

import shutil
import os
import sys

if sys.platform == 'win32':
    # os.environ['OCTAVE_EXECUTABLE'] = shutil.which('octave')
    # >> I had to replace this with this other line >>

    os.environ['OCTAVE_EXECUTABLE'] = shutil.which('octave-cli.exe')
ChesuCR
  • 9,352
  • 5
  • 51
  • 114
1

There's two executables, octave-cli.exe and octave-cli-4.4.1.exe. What if you try the one without the version number? I only needed to restart the Spyder IDE for it to work

T.C. Helsloot
  • 151
  • 1
  • 7
1

The documentation (http://blink1073.github.io/oct2py/source/installation.html) mentions oct2py may in fact be tryin to find a file called octave.exe, not octave-cli.exe

Try modifying your OCTAVE_EXECUTABLE to point to that instead. Though, in theory, if octave.exe and octave-cli.exe both sit in the same directory, adding to path should have worked ... but try anyway!

Tasos Papastylianou
  • 21,371
  • 2
  • 28
  • 57
  • 1
    It appears that, somewhere along the line, octave.exe got replaced with octave-cli.exe. There is no longer an octave.exe distributed with the Octave package. Others have successfully pointed OCTAVE_EXECUTABLE at octave-cli.exe. Thanks, though. – John Chrysostom Feb 13 '19 at 12:36
  • @JohnChrysostom might still be worth a try creating a symbolic link (or renaming) from octave-cli.exe to octave.exe though. (PS. Great honour, your eminence. Big fan of the liturgy :p ) – Tasos Papastylianou Feb 13 '19 at 14:10
1

Not sure if this will help so long after the OP, but here is what worked for me:

  1. Download Octave as a .7z file and unzip it to hard disk
  2. Run post-install.bat (from the folder entitled octave-5.2.0-w64 or something similar)
  3. Restart Windows 10 machine (due to messages encountered during run of post-install.bat)
  4. Run octave-firsttime.vbs
  5. Quit the Octave program
  6. Execute the following python code (in 3.7.6)
import os

pathToExecutable = (
    'D:\\wherever\\you\\put\\this\\octave-cli.exe'
)
os.environ['OCTAVE_EXECUTABLE'] = pathToExecutable
from oct2py import octave

I was running into a problem because, first of all, I failed to comprehend that I needed to install an Octave interpreter (I thought oct2py came with one) and then since I am not an administrator I figured I would never be able to install it, but I worked it out!

brethvoice
  • 350
  • 1
  • 4
  • 14
  • 1
    So I am just getting into using Octave, for the first time ever...step 5 above might not be necessary. All I know is that it definitely does not cause an error with the import statement; I figured it might cause problems if both Python and GNU Octave were both calling the interpreter at the same time, but then again, maybe it wouldn't! – brethvoice Mar 31 '20 at 13:30
0

Using Windows 10 and local user installation of Octave 6.2.0 creating new user environment Variable:

OCTAVE_EXECUTABLE

and setting to: %LOCALAPPDATA%\Programs\GNU Octave\Octave-6.2.0\mingw64\bin\octave-cli.exe

worked for me. I did not need admin rights for this.

Marco
  • 580
  • 7
  • 10