{
  "id": "python/pip-venv-no-pip-ensurepip-missing",
  "signature": "ModuleNotFoundError: No module named 'pip' after python -m venv .venv && source .venv/bin/activate",
  "signature_zh": "ModuleNotFoundError：python -m venv .venv && source .venv/bin/activate 后找不到名为 'pip' 的模块",
  "regex": "ModuleNotFoundError:\\ No\\ module\\ named\\ 'pip'\\ after\\ python\\ \\-m\\ venv\\ \\.venv\\ \\&\\&\\ source\\ \\.venv/bin/activate",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "创建 venv 时未包含 pip。这发生在 Debian/Ubuntu 上未安装 python3-venv 时，或使用 --without-pip 创建 venv 时，或某些最小化 Docker 镜像中。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "pip is not available to install itself; the module is missing.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Installs pip for the system interpreter, not inside the venv.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "rm -rf .venv && python3 -m venv .venv && source .venv/bin/activate && python -m pip --version",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "python -m ensurepip --upgrade",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "sudo apt update && sudo apt install python3-venv python3-pip",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.89,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}