Skip to content

Wrong Python path reported in uv python list #6515

@adaamz

Description

@adaamz

Hi,
I think I misunderstand uv python list command or it returns something I wouldn't expect 🤔

FROM python:3.9.19-slim-bookworm
RUN python3 -m venv /opt/venv
RUN uv pip install ruff

This fails on error: No virtual environment found
but when I add /opt/venv to $PATH

FROM python:3.9.19-slim-bookworm
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN uv pip install ruff

then this passes and it is OK I guess.
But the small issue is that uv python list --only-installed reports the same thing in both cases (with and without $PATH replaced)

from the Docker container:

root@7d4f7b1a5615:/# echo $PATH
/usr/local/bin/
root@7d4f7b1a5615:/# uv python list --only-installed
cpython-3.9.19-linux-x86_64-gnu    usr/local/bin/python3.9
cpython-3.9.19-linux-x86_64-gnu    usr/local/bin/python3 -> python3.9
cpython-3.9.19-linux-x86_64-gnu    usr/local/bin/python -> python3

root@7d4f7b1a5615:/# export PATH=/opt/venv/bin:$PATH
root@7d4f7b1a5615:/# echo $PATH
/opt/venv/bin:/usr/local/bin/
root@7d4f7b1a5615:/# uv python list --only-installed
cpython-3.9.19-linux-x86_64-gnu    usr/local/bin/python3.9
cpython-3.9.19-linux-x86_64-gnu    usr/local/bin/python3 -> python3.9
cpython-3.9.19-linux-x86_64-gnu    usr/local/bin/python -> python3

I would expect /opt/venv/bin/python3 here... or do I miss/understand something?

which returns /opt/venv/bin/python3 correctly

root@7d4f7b1a5615:/# /usr/bin/which python3
/opt/venv/bin/python3
root@7d4f7b1a5615:/# /usr/bin/which python3.9
/opt/venv/bin/python3.9

uv 0.3.2

Metadata

Metadata

Assignees

Labels

questionAsking for clarification or support

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions