Using Jupyterlab on Linux with uv as package manager
On Linux, installing packages into the system Python is generally discouraged because the interpreter may be managed by the operating system. For project work, use a virtual environment instead.
I use uv to manage Python environments and dependencies for research projects. However, JupyterLab is only an exploratory tool, so I do not want it to become a permanent project dependency.
There are two practical ways to use JupyterLab with a uv project.
Option 1: Use a Shared JupyterLab Environment
Create a separate virtual environment for JupyterLab:
python3 -m venv ~/.venvs/jupyter
~/.venvs/jupyter/bin/pip install jupyterlabIn the uv project, install ipykernel as a development dependency:
uv add --dev ipykernelRegister the project environment as a Jupyter kernel:
uv run ipython kernel install \
--user \
--env VIRTUAL_ENV "$(pwd)/.venv"
--name my-project \
--display-name "Python (my-project)"Start JupyterLab from the shared environment:
~/.venvs/jupyter/bin/jupyter labThen select Python (my-project) as the notebook kernel.
This approach works well when one JupyterLab installation is shared across many projects.
Option 2: Run JupyterLab Temporarily with uv
uv can provide JupyterLab only for the current command:
uv run --with jupyter jupyter labJupyterLab is downloaded and made available for the session, but it is not added to the project's dependencies.
For a dedicated project kernel, first install and register ipykernel:
uv add --dev ipykernel
uv run ipython kernel install \
--user \
--env VIRTUAL_ENV "$(pwd)/.venv"
--name my-project \
--display-name "Python (my-project)"Then launch JupyterLab:
uv run --with jupyter jupyter labAdding Notebook Dependencies
Add reproducible project dependencies with:
uv add pandas matplotlib scikit-learnAvoid installing packages manually inside the notebook when possible. Using uv add keeps pyproject.toml, uv.lock, and the project environment synchronized.
Recommendation
For occasional notebook work, the simplest option is:
uv add --dev ipykernel
uv run --with jupyter jupyter labThis keeps the system Python untouched, the project dependencies clean, and JupyterLab available whenever it is needed.
