pip error: externally-managed-environment
Sun May 3 6:35 pm EDT 2026
Key points
- This error occurs when attempting to use pip in a Python environment managed by OS such as Ubuntu 23.04 or higher.
- Create a virtual environment for you where you can use pip without limitation.
How to do it
Install required packages:
sudo apt install python3-pip
sudo apt install python3.12-venv
Go to your home directory and create your new environment:
cd
python3 -m venv .venv
Activate the environment:
source .venv/bin/activate
Now, you can install your packages like this:
pip install your_package_name
When returning to the system's default environment, use the following command:
deactivate