python install_error ai_generated true

error: externally-managed-environment

ID: python/pip-subprocess-error-externally-managed-environment

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-01-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active — — —

Root Cause

PEP 668 prevents pip from installing packages into the system Python environment to avoid conflicts with the OS package manager. This occurs on Debian/Ubuntu and similar distributions.

generic

中文

PEP 668 阻止 pip 将包安装到系统 Python 环境中,以避免与操作系统包管理器冲突。这通常发生在 Debian/Ubuntu 等发行版上。

Workarounds

  1. 98% success
    python3 -m venv myenv && source myenv/bin/activate && pip install package_name
  2. 70% success
    pip install --break-system-packages package_name
  3. 90% success
    pipx install package_name

Dead Ends

Common approaches that don't work:

  1. 90% fail

    Root privileges do not bypass the externally-managed-environment check; the error persists.

  2. 80% fail

    Reinstalling pip does not change the environment management policy.

  3. 95% fail

    This environment variable is unrelated to PEP 668 enforcement.