Difference between revisions of "Jupyterhub"
(→Installing Python packages from Digital Research Alliance of Canada wheelhouse) |
|||
Line 38: | Line 38: | ||
Restart your JupyterHub session to view and use your virtual environment named <code>my_env_py311_JH</code>. | Restart your JupyterHub session to view and use your virtual environment named <code>my_env_py311_JH</code>. | ||
− | [[File:JupyterHub_ipykernel.png|frameless|upright= | + | |
+ | [[File:JupyterHub_ipykernel.png|frameless|upright=3.5]] | ||
(Under Construction) | (Under Construction) |
Revision as of 17:11, 17 April 2024
Using JupyterHub and JupyterLab
JupyterLab is the next-generation of Jupyter notebooks. It is setup in a multi-user fashion using the JupyterHub web application. Logging in
To log in, just go to JupyterHub link. You will need to enter your username and password to log in.
To log out, select Hub, then Log Out from the JupyterHub interface.
The JupyterHub interface
JupyterHub provides two ways of working: using Jupyter Notebooks (you create a notebook and execute code as a set of “cells”, with results and documentation appearing inline), or as a more traditional text editor and IPython console.
To start a new notebook, select the Python 3 option from the menu. To execute a cell, enter the code you want to run and press Shift-Enter.
To start a new script, create a new file in the text editor and save it with an extension of “.py”. Right-clicking on the text editor will let you create a new Python 3 console for your session. You can execute code line-by-line using Shift-Enter.
More information about the JupyterHub interface can be found here. Adding new Jupyter kernels
JupyterHub is a web interface that sends commands to Python process running in the background. This Python process, called a kernel, is what is actually executing your code. We’ve setup JupyterHub with a few common kernels for common Python configurations and R. If you want to add a kernel (from say a custom Python environment or other programming language), follow the instructions for your kernel from here.
Note: conda is not recommended as it may lead to conflicts with the cvmfs software stack that is part of both CAC and the Digital Research Alliance of Canada. We strongly recommend using virtualenvironment instead.
Installing Python packages from Digital Research Alliance of Canada wheelhouse
The default python kernel on the launcher does not have access to Digital Research Alliance of Canada wheelhouse https://docs.alliancecan.ca/wiki/Available_Python_wheels. You can use the Frontenac cluster and/or the Terminal
on the launcher window of JupyterHub to install required packages in a virtual environment and make it visible on your JupyterHub.
[user@caclogin03 ~]$ module load python/3.11 [user@caclogin03 ~]$ virtualenv my_env_py311 [user@caclogin03 ~]$ source my_env_py311/bin/activate (my_env_py311) [user@caclogin03 ~]$ pip install numpy --no-index #include any required packages (my_env_py311) [user@caclogin03 ~]$ pip install ipykernel --no-index (my_env_py311) [user@caclogin03 ~]$ python -m ipykernel install --user --name my_env_py311 --display-name "my_env_py311_JH" [user@caclogin03 ~]$ deactivate
Restart your JupyterHub session to view and use your virtual environment named my_env_py311_JH
.
(Under Construction)