Home > Backend Development > Python Tutorial > How to Resolve the \'error: externally-managed-environment\' with pip3 on Linux?

How to Resolve the \'error: externally-managed-environment\' with pip3 on Linux?

Mary-Kate Olsen
Release: 2024-12-08 20:45:12
Original
1036 people have browsed it

How to Resolve the

Troubleshooting "error: externally-managed-environment" When Using pip 3

When encountering the "error: externally-managed-environment" error while using pip 3 on a Linux machine (e.g., Debian, Ubuntu), it indicates that the system is configured to manage Python packages externally.

To avoid this error and maintain system stability, it is recommended to install Python libraries and applications in a virtual environment. There are two common solutions for this:

  1. Using a virtual environment creation tool:

    • Consider using pipx to install Python applications:

      apt install pipx
      pipx install some-python-application
      Copy after login
  2. Creating a virtual environment manually:

    • Utilize Python's venv module:

      python -m venv my-venv
      my-venv/bin/pip install some-python-library
      Copy after login

      However, if installing packages "system-wide" is deemed necessary, despite the potential risks, one can:

  • Pass the --break-system-packages argument to pip.
  • Add the following lines to ~/.config/pip/pip.conf:

    [global]
    break-system-packages = true
    Copy after login

The above is the detailed content of How to Resolve the \'error: externally-managed-environment\' with pip3 on Linux?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template