{
  "id": "python/pip-editable-install-missing-pth",
  "signature": "ModuleNotFoundError: No module named 'mypkg'  # after pip install -e . succeeded",
  "signature_zh": "ModuleNotFoundError：没有名为 'mypkg' 的模块  # 在 pip install -e . 成功后",
  "regex": "ModuleNotFoundError:\\ No\\ module\\ named\\ 'mypkg'\\ \\ \\#\\ after\\ pip\\ install\\ \\-e\\ \\.\\ succeeded",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "Editable install created a __editable__*.pth file pointing at a path that no longer exists (moved project, renamed package dir), or the .pth was not picked up because site-packages is not on sys.path.",
  "root_cause_type": "generic",
  "root_cause_zh": "可编辑安装创建了一个 __editable__*.pth 文件，指向不再存在的路径（项目被移动、包目录被重命名），或因为 site-packages 不在 sys.path 上而未加载该 .pth。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "If the project was moved, pip regenerates the same stale path or a duplicate .pth.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hardcodes a machine-specific path and does not fix the broken editable metadata.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "python -m pip uninstall -y mypkg\ncd /current/path/to/project\npython -m pip install -e .",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "python - <<'PY'\nimport site, pathlib\nfor sp in site.getsitepackages():\n    for pth in pathlib.Path(sp).glob('__editable__*mypkg*.pth'):\n        print(pth, '->', pth.read_text().strip())\nPY\n# then remove stale entries and reinstall",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}