[Python] How can I setup my Virtual Environment so it is not externally managed on a Raspberry...

Discussão em 'Python' iniciado por Stack, Agosto 3, 2025.

  1. Stack

    Stack Membro Participativo

    Input:

    cd path/to/project
    sudo python3 -m venv .venv
    source .venv/bin/activate
    sudo pip install -r requirements.txt


    Output:

    error: externally-managed-environment

    × This environment is externally managed
    ╰─> 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.

    For more information visit http://rptl.io/venv

    note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
    hint: See PEP 668 for the detailed specification.


    I am trying to download the required packages on my Raspberry Pi for a project. I understand that there are very similar questions out there (e.g. How do I solve "error: externally-managed-environment" every time I use pip 3?, pip install -r requirements.txt is failing: "This environment is externally managed"). However, in my case, I believe I have already created and started the virtual environment in my project directory. Is my virtual environment setup incorrectly, or is there something else that I am missing?

    If it helps, the requirements.txt file includes the following:

    mysql-connector-python==9.4.0

    Continue reading...

Compartilhe esta Página