[Python] Python Venv won't connect to virtual environment

Discussão em 'Python' iniciado por Stack, Janeiro 25, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to install any packages to venv, but the pip install command's target directory is always /opt/homebrew/lib/python3.12/site-packages/, but I'd expect it to be something under venv.

    Here is how to replicate in my local machine:

    1. python3.12 -m venv venv to create venv
    2. source venv/bin/activate to load the environment
    3. My which python3.12 and which pip3.12 all points to the correct path, i.e., <repo_directory>/venv/bin/python3.12

    Then, when I try pip3.12 install hello-world, it shows:

    Collecting hello-world
    Using cached hello_world-0.2-py3-none-any.whl
    Installing collected packages: hello-world
    Successfully installed hello-world-0.2
    WARNING: Target directory /opt/homebrew/lib/python3.12/site-packages/hello.py already exists. Specify --upgrade to force replacement.
    WARNING: Target directory /opt/homebrew/lib/python3.12/site-packages/hello_world-0.2.dist-info already exists. Specify --upgrade to force replacement.
    WARNING: Target directory /opt/homebrew/lib/python3.12/site-packages/bin already exists. Specify --upgrade to force replacement.


    I have been stuck here for days. Any help is appreciated!

    Continue reading...

Compartilhe esta Página