GSoC 2021: How to setup the Octave kernel for Jupyter

Hello there. In this blog post, I will describe how to install and configure the Octave kernel for Jupyter. Let’s get started.

This is a companion discussion topic for the original entry at
1 Like

Grettings, someone mentioned your post in another topic when talking about the qt toolkit in jupyter I read your wordpress posts, then the last part about tricking jupyter into using the qt,

This is because the Octave kernel uses the `octave-cli` executable to run the kernel. the `octave-cli` executable doesn’t support qt which enables you to have more beautiful plots. There is two way to do this.
  • Make a symbolic link to the octave executable:
    • Create the symbolic link by running : ln -s path_to_octave_binary /usr/bin/octave-cli-jupyter
    • Export the symbolic link by running export OCTAVE_EXECUTABLE=octave-cli-jupyter

it is possible to replicate that part in Windows?, the symbolic link command in Linux links the octave directory to another called octave-cli-jupyter

but then the export command seems to reroute the OCTAVE_EXECUTABLE variable to the new linked folder?

how would this be achievable in Windows? for example

ln -s path_to_octave_binary                         /usr/bin/octave-cli-jupyter

would be changed for something like

mklink  /D "C:\Octave\octave-cli-jupyter" "C:\Octave\Octave-4.4.1\bin"

but I don’t know if

export OCTAVE_EXECUTABLE=octave-cli-jupyter

would be equivalent to

SET OCTAVE_EXECUTABLE=octave-cli-jupyter

I mainly ask since I have been testing some old code with plots that I think it would look good in a notebook, that runs fine in Octave GUI, but when I run it in a jupyter notebook I get this:

Thanks for reading.

First: I don’t use Jupyter. So I didn’t test anything.

IIUC, Abdallah wrote about creating a symlink to the Octave binary (not a directory).
There is an additional issue (hopefully fixed for Octave 7.x) that prevents using the octave.exe directly on Windows. So for creating the symlink, you’d use:

mklink "C:\Octave\octave-cli-jupyter.exe" "C:\Octave\Octave-4.4.1\bin\octave-gui.exe"

(Needs to be adapted to wherever you installed Octave.
I’d guess that the link target needs to be in your Windows search PATH for it to be found by the Jupyter kernel. Since the path with the Octave executables needs to be in the search path anyway probably, I’d guess you could create the symlink there:

mklink "C:\Octave\Octave-4.4.1\bin\octave-cli-jupyter.exe" "C:\Octave\Octave-4.4.1\bin\octave-gui.exe"

Octave 4.4.1 is quite old by now. Why don’t you use a newer version?


Ok here is what I could get from experimenting with several options in Windows

making a link that points to gui.exe as

mklink "C:\Octave\Octave-4.4.1\bin\octave-cli-jupyter.exe" "C:\Octave\Octave-4.4.1\bin\octave-gui.exe"

times out and opens a window about the application having to close suddenly

is the same as pointing the Enviromental variable to the gui.exe which results in jupyter sending error windows about a process crashing, in fact oppening the link yields


tried to make a link with directions to vbs in the same way the shortcut in the desktop does, but this link doesn’t work

mklink "C:\Octave\Octave-4.4.1\bin\octave-cli-jupyter.exe" "C:\Octave\Octave-4.4.1\octave.vbs --no-gui"

I also tried pointing the enviromental variable to gui.exe with option --no-gui

C:\Octave\Octave-4.4.1\bin\octave-gui.exe --no-gui

it goes the same way as with the symbolic link, and running the command line also crashes


finally I tried to make one file that pointed to the vbs with --no-gui option, but it also didn’t work, I guess linking jupyter with octave in windows is more difficult cause of the way the executables function


As for the versions, I have been juggling between 4.4.1 and the newest releases since of course I want the scripts and functions I make to be up to date and take advantage of the new added functions and such, but I also use some funtions made by others that used to work well on 4.4.1 but have been having problems working completely on newer releases

those functions mainly are for geography and geodesy

for example I created one of those figures in 4.4.1 and the other in 6.4.0 which I just downloaded, for some reason the figures in 6.4.0 sometimes get stuck when resizing them, I don’t know why but the plots sometimes doesn’t change size correctly when resizing figures

Others like the functions for this one

had a problem in 5 with a shortcircuit comparisson, that got fixed in 6, but now in 6 it has another problem

error: regexprep: the input string is invalid UTF-8
error: called from
    text at line 176 column 14
    mgrid at line 491 column 4

i looked at the code and the problem comes from this

L{k}=sprintf([' %3.0f' char(176) labname(nam) ' '],vals(k));

which i believe is related when calling char(176) the symbol for degress " º ", in version 4 it didn’t have a problem now in 6.x.x versions it can complete execution because of that one error.

Please, don’t take over this thread with completely unrelated questions.
You are welcome to open separate threads for each of the additional questions and I (or someone else) will be happy to help you.