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
Mary-Kate OlsenOriginal
2024-12-08 20:45:121020browse

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
  2. Creating a virtual environment manually:

    • Utilize Python's venv module:

      python -m venv my-venv
      my-venv/bin/pip install some-python-library

      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

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!

Statement:
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