Jupyter: Difference between revisions

From miki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
The [http://jupyter.org/ Jupyter] Notebook is a web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text.
The [http://jupyter.org/ Jupyter] Notebook is a web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text.

== References ==
* [http://jupyter.org/ Jupyter]
* [https://github.com/ipython/ipython/wiki/IPython-kernels-for-other-languages IPython/Jupyter kernels]


== Install ==
== Install ==
Line 11: Line 15:
jupyter notebook
jupyter notebook
</source>
</source>

=== 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''' &mdash; installed locally in user home {{file|~/.ipython}} / {{file|~/.jupyter}}.
* '''Sage 6.10''' &mdash; installed in {{file|/sage}}.

First starts sage and register the kernel using '''SageKernelSpec''' [http://doc.sagemath.org/html/en/reference/repl/sage/repl/ipython_kernel/install.html]
<source lang=bash>
/sage/sage
</source>
<source lang=python>
sage: from sage.repl.ipython_kernel.install import SageKernelSpec
sage: spec = SageKernelSpec()
sage: spec.update() # not tested
</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/}}
<source lang=bash>
$ find -name kernel.json
./local/share/jupyter/kernels/sagemath/kernel.json
</source>
: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:
<source lang=bash>
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
</source>
From now on sage is available in Jupyter notebook. Note that we don't need to start sage separately.

Revision as of 19:19, 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 ./local/share/jupyter/kernels/sagemath/
$ find -name kernel.json
./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:
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.