Difference between revisions of "Jupyterlab"

From CT Wiki
Jump to navigation Jump to search
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
Jupyterlab is a popular interactive Python notebook manager. This service runs on a Stoomboot node with 64 cores and 512 GB memory.
 
Jupyterlab is a popular interactive Python notebook manager. This service runs on a Stoomboot node with 64 cores and 512 GB memory.
  
To use the service go to https://callysto.nikhef.nl/ and log on via Nikhef SSO. The notebook will run under your Nikhef account with full access to your home directory, project and data shares, and dCache.
+
=== Accessing the service ===
  
To customize your Python environment, go to File→New→Terminal and use e.g.
+
Jupyterhub is available exclusively for Nikhef users. You have to be on the Nikhef network or use [[EduVPN]] to access the service.
  
    pip install --user matplotlib
+
To use it go to https://callysto.nikhef.nl/ and log on via Nikhef SSO. The notebook will run under your Nikhef account with full access to your home directory, project and data shares, and dCache.
  
 
==== Setting up new environments ====
 
==== Setting up new environments ====
  
 
===== Using conda =====
 
===== Using conda =====
 +
source /opt/tljh/user/etc/profile.d/conda.sh
 
  conda create --name python38 python=3.8
 
  conda create --name python38 python=3.8
 
  conda activate python38
 
  conda activate python38
Line 15: Line 16:
 
  python -m ipykernel install --user --name python38 --display-name 'Python 3.8'
 
  python -m ipykernel install --user --name python38 --display-name 'Python 3.8'
  
This installs in $HOME/.local/share/jupyter/kernels/python38.
+
This creates a new conda environment in the directory <code>$HOME/.conda/envs/python38</code> and installs the jupyter kernel in <code>$HOME/.local/share/jupyter/kernels/python38</code>.
 +
 
 +
===== Using conda in e.g. a shared project directory (work in progress) =====
 +
Add the new conda environments dir to your conda config, for example:
 +
source /opt/tljh/user/etc/profile.d/conda.sh
 +
conda config --append envs_dirs /project/myfirstproject/conda/envs
 +
 
 +
Check via
 +
conda config --get envs_dirs
 +
or the contents of
 +
$HOME/.condarc
 +
 
 +
To create a new conda environment there, you need to specify the whole path:
 +
source /opt/tljh/user/etc/profile.d/conda.sh
 +
conda create --prefix /project/myfirstproject/conda/envs/shared_python38 python=3.8
 +
conda activate shared_python38
 +
conda install ipykernel
 +
python -m ipykernel install --user --name shared_python38 --display-name 'Python 3.8 (shared)'
 +
 
 +
Note that the name given to the kernel can be (but doesn't have to be) different from the name of the conda environment.
  
 
===== Using python venv =====
 
===== Using python venv =====
Line 23: Line 43:
 
  python -m ipykernel install --user --name testing123 --display-name 'Testing 1,2,3'
 
  python -m ipykernel install --user --name testing123 --display-name 'Testing 1,2,3'
  
This installs in $HOME/.local/share/jupyter/kernels/testing123.
+
This creates a new python venv in <code>$PWD/testing123</code> and installs the jupyter kernel in <code>$HOME/.local/share/jupyter/kernels/testing123</code>.
  
 
==== List/remove/etc the kernel ====
 
==== List/remove/etc the kernel ====
Line 35: Line 55:
 
  conda env list
 
  conda env list
 
  conda env remove -n python38
 
  conda env remove -n python38
* python venv based:
+
* python venv based: remove the previously created testing123 python environment directory and its contents.
  rm -rf testing123
+
  "rm -rf ${path_to_testing123}"

Revision as of 18:29, 4 November 2021

Jupyterlab is a popular interactive Python notebook manager. This service runs on a Stoomboot node with 64 cores and 512 GB memory.

Accessing the service

Jupyterhub is available exclusively for Nikhef users. You have to be on the Nikhef network or use EduVPN to access the service.

To use it go to https://callysto.nikhef.nl/ and log on via Nikhef SSO. The notebook will run under your Nikhef account with full access to your home directory, project and data shares, and dCache.

Setting up new environments

Using conda
source /opt/tljh/user/etc/profile.d/conda.sh
conda create --name python38 python=3.8
conda activate python38
conda install ipykernel
python -m ipykernel install --user --name python38 --display-name 'Python 3.8'

This creates a new conda environment in the directory $HOME/.conda/envs/python38 and installs the jupyter kernel in $HOME/.local/share/jupyter/kernels/python38.

Using conda in e.g. a shared project directory (work in progress)

Add the new conda environments dir to your conda config, for example:

source /opt/tljh/user/etc/profile.d/conda.sh
conda config --append envs_dirs /project/myfirstproject/conda/envs

Check via

conda config --get envs_dirs

or the contents of

$HOME/.condarc

To create a new conda environment there, you need to specify the whole path:

source /opt/tljh/user/etc/profile.d/conda.sh
conda create --prefix /project/myfirstproject/conda/envs/shared_python38 python=3.8
conda activate shared_python38
conda install ipykernel
python -m ipykernel install --user --name shared_python38 --display-name 'Python 3.8 (shared)'

Note that the name given to the kernel can be (but doesn't have to be) different from the name of the conda environment.

Using python venv
python -m venv testing123
source testing123/bin/activate
pip install ipykernel
python -m ipykernel install --user --name testing123 --display-name 'Testing 1,2,3'

This creates a new python venv in $PWD/testing123 and installs the jupyter kernel in $HOME/.local/share/jupyter/kernels/testing123.

List/remove/etc the kernel

jupyter-kernelspec help
jupyter-kernelspec list
jupyter-kernelspec remove testing123

Removing environments

  • conda based:
conda env list
conda env remove -n python38
  • python venv based: remove the previously created testing123 python environment directory and its contents.
"rm -rf ${path_to_testing123}"