python
install_error
ai_generated
true
没有名为 pip 的模块 # 在:python -m venv .venv && source .venv/bin/activate && pip install requests 之后
No module named pip # after: python -m venv .venv && source .venv/bin/activate && pip install requests
ID: python/pip-venv-without-pip
80%修复率
88%置信度
0证据数
2024-07-25首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
venv 使用 --without-pip 创建,或 ensurepip 不可用(Debian 的 python3-venv 分离包),因此新环境没有 pip。
English
The venv was created with --without-pip, or ensurepip is unavailable (Debian's python3-venv split package), so the new environment has no pip.
解决方案
-
95% 成功率
python -m ensurepip --upgrade python -m pip install --upgrade pip
-
97% 成功率
sudo apt install python3-venv python3-pip rm -rf .venv python3 -m venv .venv source .venv/bin/activate python -m pip install requests
无效尝试
常见但无效的做法:
-
95% 失败
pip is the thing that is missing; the command cannot run.
-
80% 失败
Mixes system and venv paths, leading to subtle import and shebang issues.