Package: octave-kernel
PrerequisitesJupyter Notebookand GNUOctave.InstallationTo install using pip:pip install octave_kernelAdd--userto 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 theoctaveexecutable to run the kernel.
Add that executable’s directory to thePATHenvironment variable or use theOCTAVE_EXECUTABLEto 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 usingjupyter kernelspec list.
If the default location is not desired, remove the directory for theoctavekernel, and install usingpython-moctave_kernel install.  Seepython-moctave_kernel install--helpfor available options.UsageTo use the kernel, run one of:jupyternotebook# or ``jupyter lab``, if available
# In the notebook interface, select Octave from the 'New' menujupyterqtconsole--kerneloctavejupyterconsole--kerneloctaveThis kernel is based onMetaKernel,
which means it features a standard set of magics (such as%%html).  For a full list of magics,
run%lsmagicin a cell.A sample notebook is availableonline.ConfigurationThe kernel can be configured by adding anoctave_kernel_config.pyfile to thejupyterconfig path.  TheOctaveKernelclass offersplot_settings,inline_toolkit,kernel_json, andcli_optionsas 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 plotsc.OctaveKernel.plot_settings=dict(backend='qt')The path to the Octave kernel JSON file can also be specified by creating anOCTAVE_KERNEL_JSONenvironment variable.The command line options to Octave can also be specified with anOCTAVE_CLI_OPTIONSenvironment 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 setmore offto prevent
a lockup when the pager is invoked in~/.octaverc.The inline toolkit is thegraphics_toolkitused to generate plots for the inline
backend.  It defaults toqt.  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 afterinline:, e.g.plot-binline:fltk.TroubleshootingKernel Times Out While StartingIf the kernel does not start, run the following command from a terminal:python-moctave_kernel.checkThis 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 ListedIf the kernel is not listed as an available kernel, first try the following command:python-moctave_kernelinstall--userIf the kernel is still not listed, verify that the following point to the same
version of python:whichpython# use "where" if using cmd.exewhichjupyterGnuplot ErrorAn error that starts withgnuplot> set terminal aqua enhanced titlecan be fixed by
addingsetenv("GNUTERM","qt");to~/.octavercon MacOS or by installinggunplot-x11and usingsetenv("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.whichoctaveIf the returned path hassnapin it, then Octave is running in a container and you will need to configure the kernel appropriately.Set the environment variableOCTAVE_EXECUTABLE="octave"echoexportOCTAVE_EXECUTABLE=\"octave\">>~/.bashrcMake a directory for the temporary plot directories that the kernel uses. Thiscannotbe a hidden directory.mkdir~/octavePlotsSetplot_dirto point to your plot directory inoctave_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 PlotSpecify 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.Local InstallationTo install from a git checkout, run:makeinstall