Skip to content

Commit df125eb

Browse files
authored
Running jupyterlab via uv tool install
1 parent 489aa7b commit df125eb

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

jupyter/jupyterlab-uv-tool-install.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Running jupyterlab via uv tool install
2+
3+
I tried to get [jupyterlab](https://jupyter.org/install) working via `uv tool install` today and ran into some sharp edges.
4+
5+
You can start like this:
6+
```bash
7+
uv tool install jupyterlab
8+
```
9+
That ran for a while and output:
10+
```
11+
Installed 4 executables: jlpm, jupyter-lab, jupyter-labextension, jupyter-labhub
12+
```
13+
It also gave me a warning about my PATH. I fixed that with:
14+
```
15+
uv tool ensure-path
16+
```
17+
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`:
18+
```bash
19+
uv tool install jupyterlab --force
20+
```
21+
Now we can start jupyterlab with:
22+
```bash
23+
jupyter-lab
24+
```
25+
## Getting %pip to work
26+
27+
This was the biggest sticking point for me. Jupyter has a useful magic command for installing packages:
28+
29+
```python
30+
%pip install llm
31+
```
32+
When I tried to run this I got this error:
33+
34+
> `/Users/simon/.local/share/uv/tools/jupyterlab/bin/python: No module named pip`
35+
36+
It turns out we have an installation with no `pip` binary.
37+
38+
There may be a better way to do this, but I found that this worked, run in a Jupyter notebook cell:
39+
40+
```python
41+
import subprocess, sys
42+
subprocess.check_call([sys.executable, "-m", "ensurepip"])
43+
```
44+
After I ran this, the `%pip` magic command worked as expected - I didn't even need to restart the kernel.

0 commit comments

Comments
 (0)