2 min read | by Jordi Prats
If you're trying to install the AWS CLI using pip on a modern system, you might run into the following error:
$ pip install --no-cache-dir awscli
error: externally-managed-environment
× This environment is externally managed
(...)
This happens because newer Python package managers enforce stricter environment management, preventing direct package installations in system-managed environments: You should be using a virtual environment to install packages. In some cases though, you might need to install packages globally. For example, when building a Docker image, you might want to install the AWS CLI globally.
To bypass this restriction, you can explicitly allow pip to modify system packages by running:
pip config set global.break-system-packages true
Once set, you can retry the installation:
pip install --no-cache-dir awscli
This should now work without issues. Keep in mind that modifying system packages directly can lead to conflicts with your package manager, so consider using a virtual environment (venv) or a package manager like apk in Alpine where possible.
Posted on 17/02/2025