uv
uv copied to clipboard
vscode cannot help installing packages (e.g.: ipykernel for notebook)
vs code cannot help installing packages as it used to
example:
uv venv- create a python notebook
dummy.ipynb(use the newly created .venv) - run any cell
vscode will prompt
if you click on "install" this usually works but as no pip is available you get
Ofc there are solutions like adding pip or installing it manually via uv pip install ipykernel but the usual workflow is broken. Not sure if another vscode extension would solve the problem or any other ideas.
anyway, still LOOOOVEEEE all your great, fast, ergonomic python tooling and looking forward for even more! ❤️
As a workaround (or solution?), you can uv venv --seed to install pip, setuptools, and wheel into the virtual env that uv creates.
I don't know if it is related, but when running jupyter notebooks I struggle to update the venv where the kernel has been loaded.
For instance, if a block fails because of the absence of a package, I could not find a way to fix it, seems "Restart kernel" is not pointing towards the latest version of the virtual environment. The funny thing is that pip list finds the package.
Edit: part of the misalignment can be due to installation with pip instead of uv pip, I do wonder where the pip-installed packages land and if they are still accessible
@casellimarco for your own debug you can try !which pip or !pip install -v pandas. Both should give you a clue about which pip you're using. I believe you're right that !uv pip install works right now (as long as you started jupyter from the uv venv)
It would be nice to have something akin to poetry run here which sources the venv before starting the process.
poetry init -n
poetry add jupyter notebook
poetry run jupyter notebook
# in notebook, shows the venv pip
!which pip
uv venv --seed
uv pip install jupyter notebook
./.venv/bin/jupyter notebook # or ./.venv/bin/python -m jupyter notebook
# in notebook, shows not-venv pip
!which pip
explicitly sourcing the venv is a workaround for you @casellimarco
uv venv --seed
uv pip install jupyter notebook
source .venv/bin/activate
jupyter notebook
# in notebook, shows venv pip
!which pip
Thanks for the help @kafonek!