python
install_error
ai_generated
true
ModuleNotFoundError:没有名为 'pip' 的模块
ModuleNotFoundError: No module named 'pip'
ID: python/pip-venv-pip-missing-after-ensurepip
80%修复率
88%置信度
0证据数
2024-06-04首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
venv 以 `--without-pip` 创建,或 ensurepip 静默失败,导致环境未安装 pip。
English
A venv was created with `--without-pip`, or ensurepip failed silently, leaving the environment without pip installed.
解决方案
-
90% 成功率
Bootstrap pip via get-pip.py: `curl -sS https://bootstrap.pypa.io/get-pip.py | python`.
-
95% 成功率
Recreate the venv without --without-pip: `rm -rf .venv && python -m venv .venv`.
无效尝试
常见但无效的做法:
-
60% 失败
On some distros (Debian/Ubuntu) ensurepip is disabled and prints a message suggesting apt install python3-pip instead.
-
95% 失败
pip is the module being invoked; the command cannot run before pip exists.