Skip to main content

'A Jupyter kernel for Octave.'

Project description

https://mybinder.org/badge_logo.svg

Prerequisites

Jupyter Notebook and GNU Octave.

Installation

To install using pip:

pip install octave_kernel

Add --user to install in the user-level environment instead of the system environment.

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 executable to run the kernel. Add that executable’s directory to the PATH environment variable or use the OCTAVE_EXECUTABLE to point to the executable itself. Note that on Octave 5 on Windows, the executable is in "Octave-5.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.

Usage

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 octave

This 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.

Configuration

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 opions 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 defaults to qt. 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.

Troubleshooting

Kernel Times Out While Starting

If the kernel does not start, run the following command from a terminal:

python -m octave_kernel.check

This can help diagnose problems with setting up integration with Octave. If in doubt, create an issue with the output of that command.

Kernel is Not Listed

If the kernel is not listed as an available kernel, first try the following command:

python -m octave_kernel install --user

If 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 jupyter

Gnuplot Error

An error that starts with gnuplot> set terminal aqua enhanced title can be fixed by adding setenv("GNUTERM","qt"); to ~/.octaverc on MacOS or by installing gunplot-x11 and using setenv("GNUTERM", "X11").

Octave-Snap (Linux)

You can check if you are using a snap version on Linux by checking the path to your Octave installation.

which octave

If the returned path has snap in it, then Octave is running in a container and you will need to configure the kernel appropriately.

  1. Set the environment variable OCTAVE_EXECUTABLE="octave"

echo export OCTAVE_EXECUTABLE=\"octave\" >> ~/.bashrc
  1. Make a directory for the temporary plot directories that the kernel uses. This cannot be a hidden directory.

mkdir ~/octavePlots
  1. Set plot_dir to point to your plot directory in octave_kernel_config.py.

c.OctaveKernel.plot_settings = dict(plot_dir='<home>/octavePlots')

where <home> is the absolute path to your home directory. Do not use ~ as this resolves to a different location for Octave-Snap.

Blank Plot

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

octave_kernel-0.34.1.tar.gz (258.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

octave_kernel-0.34.1-py2.py3-none-any.whl (34.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file octave_kernel-0.34.1.tar.gz.

File metadata

  • Download URL: octave_kernel-0.34.1.tar.gz
  • Upload date:
  • Size: 258.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for octave_kernel-0.34.1.tar.gz
Algorithm Hash digest
SHA256 4b77c50dd795b817653a3e6fea96099f23d450513c19ad7ec372dabcbafff6fe
MD5 72c84b65adaf539a51eee517ca4de2bc
BLAKE2b-256 b4159cdf037e53e8e3c63c1a5b39e01906790c77adde6bde83ffb1eebd3a3adb

See more details on using hashes here.

File details

Details for the file octave_kernel-0.34.1-py2.py3-none-any.whl.

File metadata

  • Download URL: octave_kernel-0.34.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for octave_kernel-0.34.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2364ffbe36c0a18debd4faf770645acc777ab21165719a76eef341f234a85a53
MD5 97256357035728493db1b1870eea1506
BLAKE2b-256 41372403844fe810845e2b43dcd1f90d25a3402dd6403283fb5a0cea901dc411

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page