python
install_error
ai_generated
true
/path/to/venv/bin/python:没有名为 pip 的模块
/path/to/venv/bin/python: No module named pip
ID: python/pip-venv-no-pip
80%修复率
89%置信度
0证据数
2024-11-28首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
创建虚拟环境时未包含 pip(例如 python -m venv --without-pip,或 ensurepip 损坏),因此环境内无法使用 pip。
English
A virtual environment was created without pip (e.g. python -m venv --without-pip, or a broken ensurepip), so pip is unavailable inside it.
解决方案
-
95% 成功率
source /path/to/venv/bin/activate python -m ensurepip --upgrade python -m pip install --upgrade pip
-
98% 成功率
deactivate || true rm -rf /path/to/venv python -m venv /path/to/venv source /path/to/venv/bin/activate python -m pip --version
无效尝试
常见但无效的做法:
-
95% 失败
pip is not importable inside the venv, so the command itself fails before it can install anything.
-
90% 失败
Installs pip for the system Python, not for the broken virtual environment.