python install_error ai_generated true

No module named pip # after: python -m venv .venv && source .venv/bin/activate && pip install requests

ID: python/pip-venv-without-pip

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
0Evidence
2024-07-25First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

The venv was created with --without-pip, or ensurepip is unavailable (Debian's python3-venv split package), so the new environment has no pip.

generic

中文

venv 使用 --without-pip 创建,或 ensurepip 不可用(Debian 的 python3-venv 分离包),因此新环境没有 pip。

Workarounds

  1. 95% success
    python -m ensurepip --upgrade
    python -m pip install --upgrade pip
  2. 97% success
    sudo apt install python3-venv python3-pip
    rm -rf .venv
    python3 -m venv .venv
    source .venv/bin/activate
    python -m pip install requests

Dead Ends

Common approaches that don't work:

  1. 95% fail

    pip is the thing that is missing; the command cannot run.

  2. 80% fail

    Mixes system and venv paths, leading to subtle import and shebang issues.