Go back

How to install additional packages

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.

  1. This VM comes with the default ubuntu as an admin user. So to access the Web UI and to install additional packages, Login with ubuntu user and the password you set during the first login to the Jypyter Notebook.

/img/aws/aiml/jupyter-login.png

  1. open a Terminal in your Jupyter Notebook and enter the below command to install the there package using pip.
sudo -E pip install there

Note: Don’t forget to use sudo in the above command.

/img/aws/aiml/terminal.png

/img/aws/aiml/terminal-pip-install.png

  1. Conda lets you install new languages (such as new versions of python, node, R, etc) as well as packages in those languages. For lots of scientific software, installing with conda is often simpler & easier than installing with pip - especially if it links to C / Fortran code.

Install a package using conda with below command.

sudo -E conda install -c conda-forge seaborn

/img/aws/aiml/terminal-conda-install.png

  1. 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.

  2. 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

/img/aws/aiml/new-notebook.png

/img/aws/aiml/jupyter-pip-install.png

  1. Install conda package!
!sudo conda install -c conda-forge gdal

/img/aws/aiml/jupyter-conda-install.png

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.

/img/aws/aiml/enviroment-directory.png

Go back