Installing Octave packages with Binder

I am preparing a Jupyter Notebook using an Octave kernel based on this nice example:

However I would also like to use Octave packages, first I tried the usual way to install packages on Octave by typing pkg install -forge package_name (image, in my case) in the Jupyter Notebook code cell and I got the following error message:

warning: creating installation directory /home/jovyan/octave
warning: called from
install at line 30 column 5
pkg at line 394 column 9
configure: error: in /tmp/oct-mAomxr/image-2.12.0/src': configure: error: C++ compiler cannot create executables See config.log’ for more details
checking for a sed that does not truncate output… /bin/sed
checking for octave… /srv/conda/envs/notebook/bin/octave-4.2.1
checking for mkoctfile… /srv/conda/envs/notebook/bin/mkoctfile-4.2.1
checking whether the C++ compiler works… no
pkg: error running the configure script for image.
error: called from
configure_make at line 78 column 9
install at line 192 column 7
pkg at line 394 column 9`

Then I tried to install the package with apt-get (https://wiki.octave.org/Octave_for_Debian_systems) by adding the octave-image to apt.txt. The when I tried loading the package in the Jupyter Notebook by writing pkg load image, I got the following error message:

error: package image is not installed
error: called from
load_packages at line 41 column 7
pkg at line 411 column 7`

Is there any quick fix for one these methods or another way to do it?

1 Like

I found the solution.

Consider the following example:

To be able to install Octave packages, two modifications have to be done. First, remove the line - octave from environment.yml. Second, add the following lines to apt.txt:

octave
octave-image

Then you will only need to load the package in your Jupyter Notebook. Here’s an example I made (the pkg load image near the end of the notebook):

1 Like

Do you understand why the version of octave installed via conda-forge doesn’t work but the one via apt-get does?

It seems like the method of how to install octave itself shouldn’t matter. I don’t really know anything about Octave and its packaging ecosystem so I don’t know where to even start looking. However some pointers would be good.

It would be great if people could use the conda-forge octave package via environment.yml on mybinder.org as it gives the user flexibility over which version of Octave to install.

Sorry, I don’t have any clue. I converged to the solution I proposed by trial and error. I am still new to the world of Binder and packaging.

I also tried at first to use the conda-forge octave package. And I tried to check if there was any way to make the C++ compiler work when I try to install Octave package on the go. That would have been a more flexible solution indeed. However, I also didn’t know where to start looking.