Skip to content

python -m uv no longer installs to the python specified (if prerelease) #7417

@hauntsaninja

Description

@hauntsaninja

I think this is from #7300 cc @zanieb

Using the python -m uv / python3.13 -m uv form should count as opt-in here?
Came up in https://github.com/psf/black/actions/runs/10876175035/job/30175719632?pr=4453

Setup:

λ docker run --rm -it python:3.13.0rc2 sh
Unable to find image 'python:3.13.0rc2' locally
3.13.0rc2: Pulling from library/python
56c9b9253ff9: Pull complete 
364d19f59f69: Pull complete 
843b1d832182: Pull complete 
a348c2a8d946: Pull complete 
4e73bb8758d7: Pull complete 
38ea74b559d3: Pull complete 
ecad7386bb32: Pull complete 
Digest: sha256:b40565d2da0deec1e7ae3ba7e170376cbbf8d0a5a75b2a049a980193a196b81d
Status: Downloaded newer image for python:3.13.0rc2
# curl -LsSf https://astral.sh/uv/install.sh | sh
downloading uv 0.4.10 aarch64-unknown-linux-gnu
installing to /root/.cargo/bin
  uv
  uvx
everything's installed!

To add $HOME/.cargo/bin to your PATH, either restart your shell or run:

    source $HOME/.cargo/env (sh, bash, zsh)
    source $HOME/.cargo/env.fish (fish)
# . $HOME/.cargo/env
# uv --version
uv 0.4.10
# uv pip install --python $(which python) uv
Resolved 1 package in 182ms
Prepared 1 package in 238ms
Installed 1 package in 0.62ms
 + uv==0.4.10

Failure (that's a little confusing until you realise what's going on):

# python -m uv pip install --system pypyp 
error: The interpreter at /usr is externally managed, and indicates the following:

  To install Python packages system-wide, try apt install
  python3-xyz, where xyz is the package you are trying to
  install.

  If you wish to install a non-Debian-packaged Python package,
  create a virtual environment using python3 -m venv path/to/venv.
  Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
  sure you have python3-full installed.

  If you wish to install a non-Debian packaged Python application,
  it may be easiest to use pipx install xyz, which will manage a
  virtual environment for you. Make sure you have pipx installed.

  See /usr/share/doc/python3.11/README.venv for more information.

Consider creating a virtual environment with `uv venv`.

Success with uv 0.4.9

# uv pip install --python $(which python) 'uv<0.4.10'
Resolved 1 package in 61ms
Prepared 1 package in 246ms
Uninstalled 1 package in 0.30ms
Installed 1 package in 0.52ms
 - uv==0.4.10
 + uv==0.4.9

# python -m uv --version
uv 0.4.9
# python -m uv pip install --system pypyp 
Resolved 1 package in 66ms
Prepared 1 package in 20ms
Installed 1 package in 1ms
 + pypyp==1.2.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions