cc_staff
782
edits
(More details about pip install with the default ipykernel) |
(Reviewed the introduction of custom kernels) |
||
Line 184: | Line 184: | ||
== Create your own Jupyter Application Kernel == | == Create your own Jupyter Application Kernel == | ||
It is possible to add kernels for other programming languages, for a different Python version or for a persistent virtual environment that has all required packages and libraries for your project. Refer to [http://jupyter-client.readthedocs.io/en/latest/kernels.html Making kernels for Jupyter] to learn more. | |||
The installation of a new kernel is done in two steps: | |||
# Installation of the packages that will allow the language interpreter to communicate with the Jupyter Notebook. | |||
# Creation of a file that will indicate to Jupyter Notebook how to initiate a communication channel with the language interpreter. This file is called a ''kernel spec file'', and it will be saved in a sub-folder of <code>~/.local/share/jupyter/kernels</code>. | |||
In the following sections, we provide a few examples of the kernel installation procedure. | |||
=== Julia Kernel === | === Julia Kernel === | ||
Line 197: | Line 204: | ||
<ol> | <ol> | ||
<li>Start from a clean Bash environment (this is required if you are using the Jupyter ''Terminal''): {{Command2|env -i HOME{{=}}$HOME bash -l}} | <li>Start from a clean Bash environment (this is required if you are using the Jupyter ''Terminal''): {{Command2|env -i HOME{{=}}$HOME bash -l}} | ||
<li>Load a Python module: {{Command2|module load python/3.8}} | <li>Load a Python module: {{Command2|module load python/3.8}} | ||
<li>Create a new Python virtual environment: {{Command2|virtualenv --no-download $HOME/jupyter_py3.8}} | <li>Create a new Python virtual environment: {{Command2|virtualenv --no-download $HOME/jupyter_py3.8}} | ||
<li>Activate your newly created Python virtual environment: {{Command2|source $HOME/jupyter_py3.8/bin/activate}} | <li>Activate your newly created Python virtual environment: {{Command2|source $HOME/jupyter_py3.8/bin/activate}} | ||
<li>Install the <code>ipykernel</code> library: {{Command2|prompt=(jupyter_py3.8) [name@server ~]$|pip install --no-index ipykernel}} | <li>Install the <code>ipykernel</code> library: {{Command2|prompt=(jupyter_py3.8) [name@server ~]$|pip install --no-index ipykernel}} | ||
<li>Generate the kernel spec file. | <li>Create the common <code>kernels</code> folder: {{Command2|mkdir -p ~/.local/share/jupyter/kernels}} | ||
<li>Generate the kernel spec file. Substitute <code><unique_name></code> by a name that will uniquely identify your kernel: {{Command2|prompt=(jupyter_py3.8) [name@server ~]$|python -m ipykernel install --user --name <unique_name> --display-name "Python 3.8 Kernel"}} | |||
<li>Deactivate the virtual environment and exit the temporary Bash session: {{Command2|prompt=(jupyter_py3.8) [name@server ~]$|deactivate && exit}} | <li>Deactivate the virtual environment and exit the temporary Bash session: {{Command2|prompt=(jupyter_py3.8) [name@server ~]$|deactivate && exit}} | ||
<li>Start or restart a new JupyterLab session. | <li>Start or restart a new JupyterLab session. |