Jupyter Notebook and GNU Octave.
To install using pip:
pip install octave_kernel
To install using conda:
conda config --add channels conda-forge conda install octave_kernel conda install texinfo # For the inline documentation (shift-tab) to appear.
We require the octave-cli or octave executable to run the kernel.
Add that executable's directory to the PATH environment variable or create the
environment variable OCTAVE_EXECUTABLE to point to the executable itself.
Note that on Octave 5+ on Windows, the executable is in "Octave-x.x.x.x\mingw64\bin".
We automatically install a Jupyter kernelspec when installing the
python package. This location can be found using jupyter kernelspec list.
If the default location is not desired, remove the directory for the
octave kernel, and install using python -m octave_kernel install. See
python -m octave_kernel install --help for available options.
To use the kernel, run one of:
jupyter notebook # or ``jupyter lab``, if available
# In the notebook interface, select Octave from the 'New' menu
jupyter qtconsole --kernel octave
jupyter console --kernel octaveThis kernel is based on MetaKernel,
which means it features a standard set of magics (such as %%html). For a full list of magics,
run %lsmagic in a cell.
A sample notebook is available online.
The kernel can be configured by adding an octave_kernel_config.py file to the
jupyter config path. The OctaveKernel class offers plot_settings, inline_toolkit,
kernel_json, and cli_options as configurable traits. The available plot settings are:
'format', 'backend', 'width', 'height', 'resolution', and 'plot_dir'.
cat ~/.jupyter/octave_kernel_config.py
# use Qt as the default backend for plots
c.OctaveKernel.plot_settings = dict(backend='qt')The path to the Octave kernel JSON file can also be specified by creating an
OCTAVE_KERNEL_JSON environment variable.
The command line options to Octave can also be specified with an
OCTAVE_CLI_OPTIONS environment variable. The cli options be appended to the
default options of --interactive --quiet --no-init-file. Note that the
init file is explicitly called after the kernel has set more off to prevent
a lockup when the pager is invoked in ~/.octaverc.
The inline toolkit is the graphics_toolkit used to generate plots for the inline
backend. It will default to whatever backend octave defaults to.
The different backend can be used for inline plotting either by using this configuration
or by using the plot magic and putting the backend name after inline:, e.g. plot -b inline:fltk.
The octave_kernel supports running on Linux, MacOS, or Windows. On Linux, it supports Octave installed
using apt-get, flatpak, or snap. There is no additional configuration required to use flatpak or snap.
If the kernel does not start, run the following command from a terminal:
python -m octave_kernel.checkThis can help diagnose problems with setting up integration with Octave. If in doubt, create an issue with the output of that command.
If the kernel is not listed as an available kernel, first try the following command:
python -m octave_kernel install --userIf the kernel is still not listed, verify that the following point to the same version of python:
which python # use "where" if using cmd.exe
which jupyterIn some cases, the qt graphics toolkit is only available when running with a
display enabled.
On a remote system without a display, you can use xvfb-run to provide a virtual framebuffer. For example:
export OCTAVE_EXECUTABLE="xvfb-run octave"Or in the config file:
c.OctaveKernel.executable = "xvfb-run octave"To enable Octave's Qt graphics toolkit in a JupyterHub environment (or any headless server), you need a virtual display. Install the required system packages:
apt-get install -y octave libglu1 xvfb texinfo fonts-freefont-otf ghostscriptStart Xvfb before launching JupyterHub (or in a server startup script):
Xvfb :99 -screen 0 1024x768x24 &
export DISPLAY=:99Then configure the kernel to use the Qt backend:
# ~/.jupyter/octave_kernel_config.py
c.OctaveKernel.plot_settings = dict(backend="qt")For Binder-based deployments, place a start script in the binder/ directory to launch Xvfb and export DISPLAY before the server starts, and list the required packages in binder/apt.txt.
Specify a different format using the %plot -f <backend> magic or using a configuration setting.
On some systems, the default 'png' produces a black plot. On other systems 'svg' produces a
black plot.
To install from a git checkout run:
pip install -e .