In your JupyterLab session, go to the Launcher and start a new Terminal
Add a Python kernel
Create a conda environment with the required Python version:
module load conda
conda create -n <your-env-name> python=3.7 ipykernel
Don’t forget to include the
ipykernel
package that will be required to use your conda environment in JupyterLab.Add any other required libraries to the environment
Using conda :
conda activate <your-env-name>
conda install <package>
conda deactivate
Using pip :
conda activate <your-env-name>
pip install <package>
conda deactivate
Install a new kernel for JupyterLab based on your environment
conda activate <your-env-name>
python -m ipykernel install --user --name '<your-env-name>' --display-name "My Python env"
conda deactive
Example : create your own Numpy kernel
This ia full example to install a new kernel with the latest version of numpy :
Create a conda environment with Python, iPyKernel and Numpy
module load conda
conda create -n my-numpy -c conda-forge python ipykernel numpy
Install the kernel for JupyterLab
conda activate my-numpy
python -m ipykernel install --user --name 'my-numpy' --display-name "Numpy"
conda deactivate
Your Numpy kernel is now available in the launcher
And ready working
Add an R kernel
Create a conda environment with the required R version
module load conda
conda create -n <your-env-name> r-base=4.2.3 r-irkernel jupyter_client
Don’t forget to add the
r-irkernel
and jupyter_client
packages that a required to install your R environment in JupyterLabOf course, you can add any additionnal package you need.
Activate your conda environment and start a R session:
conda activate <your-env-name>
R
Install your R environment in JupyterLab using the IRKernel
library.
IRkernel::installspec(name = '<your-env-name>', displayname = 'My R', user = TRUE)