python
module_error
ai_generated
true
ModuleNotFoundError: No module named 'pip' after python -m venv .venv && source .venv/bin/activate
ID: python/pip-venv-no-pip-ensurepip-missing
80%Fix Rate
89%Confidence
0Evidence
2024-04-11First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
Root Cause
The venv was created without pip. This happens on Debian/Ubuntu when python3-venv is not installed, or when venv is created with --without-pip, or on some minimal Docker images.
generic中文
创建 venv 时未包含 pip。这发生在 Debian/Ubuntu 上未安装 python3-venv 时,或使用 --without-pip 创建 venv 时,或某些最小化 Docker 镜像中。
Workarounds
-
95% success
rm -rf .venv && python3 -m venv .venv && source .venv/bin/activate && python -m pip --version
-
90% success
python -m ensurepip --upgrade
-
92% success
sudo apt update && sudo apt install python3-venv python3-pip
Dead Ends
Common approaches that don't work:
-
95% fail
pip is not available to install itself; the module is missing.
-
85% fail
Installs pip for the system interpreter, not inside the venv.