[Python] pip and uv point to ~/.local/bin/ even after activating virtual environment

Discussão em 'Python' iniciado por Stack, Julho 15, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working on a python project created using uv on a ubuntu system.

    I activated virtual environment using

    source .venv/bin/activate

    which python points to

    /home/username/my-project/.venv/bin/python

    However, when I check where pip and uv is are pointing

    which pip
    which uv


    I get

    /home/username/.local/bin/pip
    /home/username/.local/bin/uv


    Instead of

    home/username/my-project/.venv/bin/pip
    home/username/my-project/.venv/bin/uv


    This is causing issues with dependencies not installing on the correct environment, and my FASTAPI project using uv isn't isloated as expected

    The issue is that there are other two FASTPI projects running in the machine and this new project has updated versions of FASTAPI and pydantic

    so installing them using python -m pip install pydantic==2.11.7 causes issues on the other two projects

    Question:

    How do I ensure that after activating the virtual environment, the venv's pip and uv take predecence over the global ones in ~/.local/bin/ ?

    The python version is 3.11

    What I've tried

    1. Deleted and recreated the .venv
    2. Actiavted sourve with .venv/bin/actiavte
    3. Verified $VIRTUAL_ENV is set correctly

    Still pip and uv default to the global user-installed versions

    Continue reading...

Compartilhe esta Página