positron
positron copied to clipboard
Using uv leads to a failed ipykernel installation
Positron Version: 2024.05.0 (Universal) build 1160 Code - OSS Version: 1.89.0 Commit: 5024068198dcf8f5c3560dce8e6bf8affd9580cb Date: 2024-05-08T03:21:09.376Z Electron: 28.2.8 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Darwin arm64 23.4.0
Steps to reproduce the issue:
- Install the
uvtool - Create a new project/folder and navigate to it.
$ uv venvto create a new virtual environment.- This will prompt Positron to ask you to use the
.venvas the default for the workspace. Select yes which will also attempt to installipykerneland select Yes. - Because
uvdoesn't includepipin the.venv, thepip install ipykernelwill fail as it needs to beuv pip install ipykernel instead
What did you expect to happen?
It would be nice if Positron could work with uv to install packages.
Were there any error messages in the output or Developer Tools console?
Cross-posting: https://dev.to/astrojuanlu/python-packaging-is-great-now-uv-is-all-you-need-4i2d
Using:
uv init
uv add ipykernel
Creates a .venv and installs ipykernel, but Positron has a popup to prefer this .venv and tries to install ipykernel with pip directly, then throws an error.
I think Positron should support uv in the project creation phase. If uv is detected, it should appear under this dropdown (along with venv and conda)
I also scratch my head trying to develop a workflow which would allow me to use Positron projects with uv-managed environments.
In #6020 we are adding support for installing pip when it is missing (in order to install ipykernel). This is going to feel real bad to uv users, so when we add support for detecting uv environments and correctly installing into them, we should also confirm we are never installing pip into uv environments.
cc @samclark2015
Note that you can use uv venv --seed to workaround this issue, because the --seed flag installs pip for you.
I'll also note that it looks like uv encodes some metadata into the pyenv.cfg and we could sniff that to use uv pip install ipykernel but I'm not sure if all the different methods of managing Python will also add that metadata:
#! pyenv.cfg
home = /Users/thomasmock/.pyenv/versions/3.12.0/bin
implementation = CPython
uv = 0.2.37 #<<-- uv version info
version_info = 3.12.0
include-system-site-packages = false
relocatable = false
prompt = uv-testing
I clarified the title of this issue to reflect the scope of what we're thinking about. To call this issue complete, we'd like to recognize uv-managed Python interpreters, and use uv to install packages in them. That should solve the bug in the original post and build the foundation for solving issues like https://github.com/posit-dev/positron/issues/5165 and https://github.com/posit-dev/positron/issues/6175.
I scoped this particular issue back to the original bug. It should be solved as of https://github.com/posit-dev/positron/pull/6294, because we no longer need to install ipykernel, so we no longer try to use pip in a pip-less environment.
The additional scope I had talked about earlier became these two issues, which can be solved separately:
- https://github.com/posit-dev/positron/issues/6476
- https://github.com/posit-dev/positron/issues/6477
Verified Fixed
Positron Version(s) : Main on 2/26/25
OS Version : ubuntu
Test scenario(s)
CI now uses uv without issue
Link(s) to TestRail test cases run or created: