1

I recently started working with Octave on Jupyter notebook. I was previously working on a Linux laptop but then I thought about creating a similar working environment on my Windows laptop. I followed more or less the same approach.

I already have Octave installed on my Windows laptop and I have added C:\Program Files\GNU Octave\Octave-6.1.0\mingw64\bin to the PATH environment variable. I also have set OCTAVE_EXECUTABLE to octave-cli in the environment variables.

I created a virtual environment using the following command.

python -m venv octave

Then I activated the virtual environment from the desired working directory and installed Jupyter in it using the following command.

pip install jupyter

Then I installed the Octave kernel using the following command.

pip install octave-kernel

After that, when I ran the following command to see if things are working or not I got the error mentioned further below.

(octave) λ python -m octave_kernel.check
Octave kernel v0.32.0
Metakernel v0.27.5
Python v3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)]
Python path: C:\Workspace\python-virtual-environments\octave\Scripts\python.exe

Connecting to Octave...
Octave connection established
[WinError 193] %1 is not a valid Win32 application

When I start jupyter-notebook and open a notebook, I end up getting the same error.

[I 15:20:33.465 NotebookApp] Kernel started: 92de579a-c8df-4cf8-9ec4-dbb9aefa1fe5, name: octave
[MetaKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "c:\workspace\python-virtual-environments\octave\lib\site-packages\ipykernel\kernelbase.py", line 265, in dispatch_shell
    yield gen.maybe_future(handler(stream, idents, msg))
  File "c:\workspace\python-virtual-environments\octave\lib\site-packages\ipykernel\kernelbase.py", line 655, in kernel_info_request
    content.update(self.kernel_info)
  File "c:\workspace\python-virtual-environments\octave\lib\site-packages\ipykernel\kernelbase.py", line 648, in kernel_info
    'language_info': self.language_info,
  File "c:\workspace\python-virtual-environments\octave\lib\site-packages\octave_kernel\kernel.py", line 78, in language_info
    'version': self.language_version,
  File "c:\workspace\python-virtual-environments\octave\lib\site-packages\octave_kernel\kernel.py", line 69, in language_version
    ver = self.octave_engine.eval('version', silent=True)
  File "c:\workspace\python-virtual-environments\octave\lib\site-packages\octave_kernel\kernel.py", line 96, in octave_engine
    logger=self.log)
  File "c:\workspace\python-virtual-environments\octave\lib\site-packages\octave_kernel\kernel.py", line 173, in __init__
    self.repl = self._create_repl()
  File "c:\workspace\python-virtual-environments\octave\lib\site-packages\octave_kernel\kernel.py", line 392, in _create_repl
    force_prompt_on_continuation=True)
  File "c:\workspace\python-virtual-environments\octave\lib\site-packages\metakernel\replwrap.py", line 63, in __init__
    encoding="utf-8")
  File "c:\workspace\python-virtual-environments\octave\lib\site-packages\metakernel\pexpect.py", line 32, in spawn
    encoding=encoding, codec_errors=codec_errors)
  File "c:\workspace\python-virtual-environments\octave\lib\site-packages\pexpect\popen_spawn.py", line 53, in __init__
    self.proc = subprocess.Popen(cmd, **kwargs)
  File "C:\Program Files\Python36\lib\subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "C:\Program Files\Python36\lib\subprocess.py", line 1017, in _execute_child
    startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application

What am I doing wrong here?


Update #1

I tried changing the OCTAVE_EXECUTABLE environment variable to octave but I got the following error.

(octave) λ python -m octave_kernel.check
Octave kernel v0.32.0
Metakernel v0.27.5
Python v3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)]
Python path: C:\Workspace\python-virtual-environments\octave\Scripts\python.exe

Connecting to Octave...
Octave connection established
OCTAVE_EXECUTABLE does not point to an octave-cli file, please see README
Bilesh Ganguly
  • 3,792
  • 3
  • 36
  • 58
  • The phrase *is not a valid Win32 application* is not about bitness. Even 64-bit Windows is `win32`: it is a software architecture not a hardware architecture. – BoarGules Feb 11 '21 at 21:44
  • are you able to run via pdb and inspect what the subprocess cmd actually is? – Tasos Papastylianou Feb 11 '21 at 22:35
  • 1
    of note, [another user had the same problem recently](https://stackoverflow.com/q/65792257/4183191), but we never got to the bottom of it ... – Tasos Papastylianou Feb 11 '21 at 22:40
  • incidentally, the [documentation](http://blink1073.github.io/oct2py/source/installation.html) seems to imply that you should be setting the OCTAVE_EXECUTABLE to `octave.exe`, not `octave-cli.exe` – Tasos Papastylianou Feb 11 '21 at 22:47
  • @TasosPapastylianou - I'm working with `octave-kernel` and setting the octave executable as mentioned here (https://pypi.org/project/octave-kernel/). But let me try to set it to `octave.exe` and see what happens. – Bilesh Ganguly Feb 12 '21 at 18:46
  • 1
    @TasosPapastylianou - Didn't work. Saying *OCTAVE_EXECUTABLE does not point to an octave-cli file, please see README* – Bilesh Ganguly Feb 12 '21 at 18:59

1 Answers1

1

It looks like the kernel used does not work with Octave 6. I had the same problem with Octave 6.2.0. OCTAVE_EXECUTABLE and PATH were set correctly according to installation instructions, but without success. The octave kernel chek error message is: [WinError 193] %1 is not a valid Win32 application. But with Octave 5.2 everything works fine. I work with jupyter under winpython 3.9.2

Problem resolved. Octave 6.2.0 and winpython 3.9.4 completely reinstalled. Path and environment variable set: Path —>D:\Octave\Octave-6.2.0\mingw64\bin OCTAVE_EXECUTABLE —> D:\Octave\Octave-6.2.0\mingw64\bin\octave-cli.exe now it works suddenly without errors with Octave 6.2.0. The only difference from the previous installation is winpython 3.9.4 instead of 3.9.2

rdst
  • 11
  • 2