JupyterLab¶
Jupyter Startup¶
The container uses conda to manage environments. Jupyter is automatically started
from jupyter_env
.
All other dependencies for working in jupyter lab are installed in worker_env
.
You can extend this environment at runtime, or create your own environments using
conda or venv
.
The default is to choose worker_env
as your Kernel after starting JupyterLab
and creating a new notebook.
Also have a look at the excellent Jupyter Docs.
Takeaway:
-
There is a base environment prepared with the name
worker_env
. You can select this environment from the list of known kernels (e.g. from the top right corner in a JupyterLab notebook). -
The Jupyter server is installed in a separate environment named
jupyter_env
.
Creating a custom environment¶
There are many ways to do this. One example is to use venv
.
- Create a new empty environment somewhere from within a notebook cell
!python -m venv ./wikidata_venv
Note
the !
tells Jupyter to treat the cell code as bash instructions, not as Python.
- Install packages to the newly created venv
./wikidata_venv/bin/python -m pip install qwikidata ipykernel pandas
- Make the Kernel available in JupyterLab
In order to select the Kernel on the top-right corner in a Jupyter notebook, install (link) ipykernel
to the venv.
./wikidata_venv/bin/python -m ipykernel install --user --name=qwikidata
See further information and alternatives under Task Guide: Updating packages and custom envs.
Tip
See an example in this notebook, where I added a further check to prevent re-installation, if the package or environment already exists.
In this notebook, a helper script pkginstall.sh
is used to reduce the effort for maintaining environments and package installs. Find the tool in this repository.