Skip to content

Commit

Permalink
Running jupyterlab via uv tool install
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw authored Mar 8, 2025
1 parent 489aa7b commit df125eb
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions jupyter/jupyterlab-uv-tool-install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Running jupyterlab via uv tool install

I tried to get [jupyterlab](https://jupyter.org/install) working via `uv tool install` today and ran into some sharp edges.

You can start like this:
```bash
uv tool install jupyterlab
```
That ran for a while and output:
```
Installed 4 executables: jlpm, jupyter-lab, jupyter-labextension, jupyter-labhub
```
It also gave me a warning about my PATH. I fixed that with:
```
uv tool ensure-path
```
On one other machine this didn't work because it refused to over-write a previous installation. The fix was to run `uv tool install` with `--force`:
```bash
uv tool install jupyterlab --force
```
Now we can start jupyterlab with:
```bash
jupyter-lab
```
## Getting %pip to work

This was the biggest sticking point for me. Jupyter has a useful magic command for installing packages:

```python
%pip install llm
```
When I tried to run this I got this error:

> `/Users/simon/.local/share/uv/tools/jupyterlab/bin/python: No module named pip`
It turns out we have an installation with no `pip` binary.

There may be a better way to do this, but I found that this worked, run in a Jupyter notebook cell:

```python
import subprocess, sys
subprocess.check_call([sys.executable, "-m", "ensurepip"])
```
After I ran this, the `%pip` magic command worked as expected - I didn't even need to restart the kernel.

0 comments on commit df125eb

Please sign in to comment.