uv icon indicating copy to clipboard operation
uv copied to clipboard

vscode cannot help installing packages (e.g.: ipykernel for notebook)

Open Julian-J-S opened this issue 1 year ago • 4 comments

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 image

if you click on "install" this usually works but as no pip is available you get image

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! ❤️

Julian-J-S avatar Feb 17 '24 16:02 Julian-J-S

As a workaround (or solution?), you can uv venv --seed to install pip, setuptools, and wheel into the virtual env that uv creates.

kafonek avatar Feb 17 '24 17:02 kafonek

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

image

casellimarco avatar Feb 19 '24 13:02 casellimarco

@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

kafonek avatar Feb 19 '24 14:02 kafonek

Thanks for the help @kafonek!

casellimarco avatar Feb 22 '24 08:02 casellimarco