Modifying your notebook environment
You have root access on the machine, so you can install anything you want using sudo. However, your machine is built from a Docker image. Any libraries you install will be lost the next time you start up. For more permanent changes, we recommend customizing the underlyig docker image.
When creating a Jupyter instance or editing one, there is a set of advanced options which allow users to customize their Python and Linux environment. We minimize it by default.
Clicking on the bar, expandes the advanced menu.
Here you can customize your Python and Linux environment (and soon, R, and Julia). Choose the appropriate option from the select box, and paste in an environment.yaml or a requirements.txt. In addition, if you want additional apt-get linux packages, you can type them in into the apt-txt option. Currently mixing environment.yaml and requirements.txt is not supported. The build can take a while (up to 10 minutes)
As a starting point, this is the environment.yml that generates the default environment available in Saturn. Feel free to use this as a reference for your own environments.
channels: - defaults - conda-forge - https://conda.saturncloud.io/pkgs dependencies: - nodejs=10.13.0 - python=3.7 - numpy=1.15.3 - pandas - ipywidgets=7.2* - numexpr - matplotlib - scipy - seaborn - scikit-learn - scikit-image - sympy - cython - patsy - statsmodels - cloudpickle - dill - numba - bokeh - sqlalchemy - hdf5 - h5py - vincent - beautifulsoup4 - protobuf - xlrd - ipykernel - dash - dash-bootstrap-components - dash-core-components - dash-daq - dash-html-components - dash-renderer - dash-tablename: saturn
Our base environment is created using Conda. We install Jupyter into /srv/conda, and the kernel into /srv/conda/envs/saturn. This kernel should be the default in the notebook.
The first time you use the JupyterLab terminal, you may need to setup conda command line interface. You can do so with the following commands.
conda init bashbash
After that, you can activate the saturn environment
conda activate saturn
Creating new environments inside your home directory
You can also use conda to create a python environment inside your home directory. Assuming you know which packages you want, you can execute the following command. Please make sure to add the ipykernel package.
$ conda create -p /home/jovyan/myenv numpy pandas matplotlib ipykernel
If you have an environment.yaml file – you can use that as well!. Just make sure you add ipykernel to the list of packages.
$ conda env create -p /home/jovyan/myenv --file env.yaml
After your environment is created, you can register it with jupyter
$ python -m ipykernel install --user --name myenv