Helix/bwVisu/JupyterLab: Difference between revisions
H Schumacher (talk | contribs) m (Changed Miniconda to Miniforge) |
H Schumacher (talk | contribs) (Added instructions to create shared conda environments / kernels) |
||
Line 47: | Line 47: | ||
<syntaxhighlight lang="bash">python3 -m ipykernel install --user --name=<myKernel></syntaxhighlight></li></ol> |
<syntaxhighlight lang="bash">python3 -m ipykernel install --user --name=<myKernel></syntaxhighlight></li></ol> |
||
=== |
=== Interactive Widgets === |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
== Python kernels == |
|||
⚫ | |||
⚫ | |||
=== Shared use of conda environments === |
|||
Follow these instructions if you want to share conda environments with your colleagues: |
|||
# Create a shared directory (optimally on SDS@hd) into wich the ipython kernels are installed, for example "conda_kernels". Never share your home directory. |
|||
# [[#Add_packages_via_conda_environments | Create a conda environment and register it as kernel]]. |
|||
#* Optional: You can add another shared directory, for example "conda_envs", to share not just the kernels but also the underlying conda environments. A conda environment can be [[Development/Conda#Reproducible_Conda_Environments | saved as a yml file]]. |
|||
# Add the new data directory to the jupyter paths: |
|||
#:<syntaxhighlight lang="bash"> |
|||
# Check the current paths |
|||
jupyter --paths |
|||
# Add the following line to your .bashrc file |
|||
export JUPYTER_DATA_DIR=<path_to_shared_directory> |
|||
</syntaxhighlight> |
|||
# Start bwVisu JupyterLab Job |
|||
=== Multi-Language Support === |
|||
JupyterLab supports over 40 programming languages including Python, R, Julia, and Scala. This is achieved through the use of different kernels. |
|||
⚫ | |||
==== R Kernel ==== |
==== R Kernel ==== |
||
Line 84: | Line 113: | ||
After that, Julia is available as a kernel. |
After that, Julia is available as a kernel. |
||
=== Interactive Widgets === |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
== FAQ == |
== FAQ == |
Revision as of 20:41, 30 June 2025
JupyterLab is an integrated development environment (IDE) that provides a flexible and scalable interface for the Jupyter Notebook system. It supports interactive data science and scientific computing across over 40 programming languages (including Python, Julia, and R).
Python version
You can see the default python version by running python --version
- Activate the Miniconda module
- Create a virtual environment with a custom python version via conda:
conda create --name <myenv> python=<python version>
- Install the ipykernel package:
conda install ipykernel
- Register your virtual environment as custom kernel to Jupyter:
python3 -m ipykernel install --user --name=<myKernel>
- Select your newly created kernel in Jupyter
Python packages
Add packages via venv virtual environments
- Open a terminal and type:
python3 -m venv <myEnv>
- Activate your environment:
source <myEnv>/bin/activate
- Install your packages:
pip install -U pip pip install <mypackage>
- Install the ipykernel package:
pip install ipykernel
- Register your virtual environment as custom kernel to Jupyter:
python3 -m ipykernel install --user --name=<myKernel>
Add packages via conda environments
- Load the miniforge module by clicking first on the blue hexagon icon on the left-hand side of Jupyter's start page and then on the "load" button right of the entry for miniforge in the software module menu.
- Open a terminal and create a conda environment:
conda create --name <myenv>
- Activate your environment:
conda activate <myenv>
- Install your packages:
conda install <mypackage>
- Install the ipykernel package:
conda install ipykernel
- Register your virtual environment as custom kernel to Jupyter:
python3 -m ipykernel install --user --name=<myKernel>
Interactive Widgets
JupyterLab supports interactive widgets that can create UI controls for interactive data visualization and manipulation within the notebooks. Example of using an interactive widget:
from ipywidgets import IntSlider slider = IntSlider() display(slider)
These widgets can be sliders, dropdowns, buttons, etc., which can be connected to Python code running in the backend.
Python kernels
Python kernels are implementations of the Jupyter notebook environment for different languages or virtual environments. You can switch between kernels easily, allowing you to use the best tool for a specific task.
By default, custom kernels are installed to ~/.local/share/jupyter/kernels/.
Follow these instructions if you want to share conda environments with your colleagues:
- Create a shared directory (optimally on SDS@hd) into wich the ipython kernels are installed, for example "conda_kernels". Never share your home directory.
- Create a conda environment and register it as kernel.
- Optional: You can add another shared directory, for example "conda_envs", to share not just the kernels but also the underlying conda environments. A conda environment can be saved as a yml file.
- Add the new data directory to the jupyter paths:
# Check the current paths jupyter --paths # Add the following line to your .bashrc file export JUPYTER_DATA_DIR=<path_to_shared_directory>
- Start bwVisu JupyterLab Job
Multi-Language Support
JupyterLab supports over 40 programming languages including Python, R, Julia, and Scala. This is achieved through the use of different kernels.
R Kernel
- On the cluster:
$ module load math/R $ R > install.packages('IRkernel')
- On bwVisu:
- Start Jupyter App
- In left menu: load math/R
- Open Console:
- Start kernel 'R 4.2' as console or notebook
$ R > IRkernel::installspec(displayname = 'R 4.2')
Julia Kernel
Load the math/julia module. Open the Terminal.
julia ] add IJulia
After that, Julia is available as a kernel.
FAQ
- My conda commands are interrupted with message 'Killed'.
Request more memory when starting Jupyter. - How can I navigate to my SDS@hd folder in the file browser?
Open a terminal and set a symbolic link to your SDS@hd folder in your home directory. For example: - Jupyterlab doesn't let me in but asks for a password.
Try using more memory for the job. If this doesn't help, try using the inkognito mode of your browser as the browser cache might be the problem. - I prefer VSCode over JupyterLab. Can I start a JupyterLab job and then connect with it via VSCode?
This is possible but, if you are a bwForCluster Helix user as well, it is not recommended as it wastes bwVisu resources. Please start the job directly on Helix instead. You can find the instructions at the VSCode page.
cd $HOME mkdir sds-hd cd sds-hd ln -s /mnt/sds-hd/sd16a001 sd16a001