Home >Backend Development >Python Tutorial >How to Resolve the \'error: externally-managed-environment\' with pip3 on Linux?
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:
Using a virtual environment creation tool:
Consider using pipx to install Python applications:
apt install pipx pipx install some-python-application
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:
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!