python
install_error
ai_generated
true
错误:外部管理的环境 × 此环境由外部管理 ╰─> 若要在系统范围安装 Python 包,请尝试 apt install python3-xyz,其中 xyz 是您尝试安装的包。
error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install.
ID: python/pip-externally-managed-environment
80%修复率
90%置信度
0证据数
2024-01-30首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
PEP 668 标记文件(EXTERNALLY-MANAGED)存在于系统 Python 的 stdlib 中,告诉 pip 不要修改操作系统管理的解释器。
English
PEP 668 marker file (EXTERNALLY-MANAGED) exists in the system Python's stdlib, telling pip not to modify the OS-managed interpreter.
解决方案
-
98% 成功率
python3 -m venv .venv source .venv/bin/activate python -m pip install requests
-
92% 成功率
sudo apt install python3-requests # or for CLI apps pipx install ruff
无效尝试
常见但无效的做法:
-
90% 失败
--user still writes into the externally-managed interpreter's user site-packages and is blocked.
-
95% 失败
Running as root does not bypass the PEP 668 marker and can corrupt OS packages.