JupyterHub is run from a python3 virtual environment located in /opt/tljh/hub. It uses the system’s installed python and is owned by root. The User Environment is a conda environment that is shared by all users in the JupyterHub. Libraries installed in this environment are immediately available to all users. Admin users can install packages in this environment with sudo -E
Follow below steps to install and use new packages.
sudo -E pip install there
Note: Don’t forget to use sudo in the above command.
Install a package using conda with below command.
sudo -E conda install -c conda-forge seaborn
The packages seaborn and there are now available to all users in JupyterHub. If a user already had a python notebook running, they have to restart their notebook’s kernel to make the new libraries available.
Alternatively, you can install the packages from jupyter notebook itself. Open a new jupyter notebook by click new dropdown and selecting Python 3 (ipykernel) from top right corner.. Run below pip installation as
!sudo pip install matplotlib
!sudo conda install -c conda-forge gdal
The user environment is a conda environment set up in /opt/tljh/user, with a python3 kernel as the default. It is readable by all users, but writeable only by users who have root access. This makes it possible for JupyterHub admins (who have root access with sudo) to install software in the user environment easily.