Jupyter: Difference between revisions

From miki
Jump to navigation Jump to search
Line 31: Line 31:
sage: spec.update() # not tested
sage: spec.update() # not tested
</source>
</source>
* This does nothing, but apparently registration requires a file named {{file|kernel.json}} [http://ask.sagemath.org/question/30163/jupyter-ipython-notebook-kernel-math-display/]. We find this file in {{file|./local/share/jupyter/kernels/sagemath/}}
* This does nothing, but apparently registration requires a file named {{file|kernel.json}} [http://ask.sagemath.org/question/30163/jupyter-ipython-notebook-kernel-math-display/]. We find this file in {{file|/sage/local/share/jupyter/kernels/sagemath/}}
<source lang=bash>
<source lang=bash>
$ find -name kernel.json
$ find /sage -name kernel.json
./local/share/jupyter/kernels/sagemath/kernel.json
/sage/local/share/jupyter/kernels/sagemath/kernel.json
</source>
</source>
:In the same tree we also find '''jsmol''' and '''mathjax''' extensions.
:In the same tree we also find '''jsmol''' and '''mathjax''' extensions.
* From iPython/Jupyter documentation [https://ipython.org/ipython-doc/3/development/kernels.html], we understand we must add the links ourselves in user's:
* From iPython/Jupyter documentation [https://ipython.org/ipython-doc/3/development/kernels.html], we understand we must add the links ourselves in user's home:
<source lang=bash>
<source lang=bash>
mkdir ~/.ipython/kernels
mkdir ~/.ipython/kernels

Revision as of 20:13, 9 February 2016

The Jupyter Notebook is a web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text.

References

Install

First install Anaconda:

bash Anaconda2-2.5.0-Linux-x86_64.sh

To start the server:

jupyter notebook

Sagemath kernel

We can register sage to have it available as a kernel in Jupyter. Here the recipe I followed using

  • Ubuntu 14.04 LTS
  • Jupyter 4.10 — installed locally in user home ~/.ipython / ~/.jupyter.
  • Sage 6.10 — installed in /sage.

First starts sage and register the kernel using SageKernelSpec [1]

/sage/sage
sage: from sage.repl.ipython_kernel.install import SageKernelSpec
sage: spec = SageKernelSpec()
sage: spec.update()  # not tested
  • This does nothing, but apparently registration requires a file named kernel.json [2]. We find this file in /sage/local/share/jupyter/kernels/sagemath/
$ find /sage -name kernel.json
/sage/local/share/jupyter/kernels/sagemath/kernel.json
In the same tree we also find jsmol and mathjax extensions.
  • From iPython/Jupyter documentation [3], we understand we must add the links ourselves in user's home:
mkdir ~/.ipython/kernels
ln -sf /sage/local/share/jupyter/kernels/sagemath ~/.ipython/kernels
ln -sf /sage/local/share/jsmol                    ~/.ipython/nbextensions
ln -sf /sage/local/share/mathjax                  ~/.ipython/nbextensions

From now on sage is available in Jupyter notebook. Note that we don't need to start sage separately.