{
  "id": "python/pip-name-normalization-conflict",
  "signature": "ERROR: Cannot install my-pkg and my_pkg because they depend on different versions of the same package, but they are the same project (normalized name: my-pkg).",
  "signature_zh": "错误：无法安装 my-pkg 和 my_pkg，因为它们依赖同一包的不同版本，但它们是同一个项目（规范化名称：my-pkg）。",
  "regex": "ERROR:\\ Cannot\\ install\\ my\\-pkg\\ and\\ my_pkg\\ because\\ they\\ depend\\ on\\ different\\ versions\\ of\\ the\\ same\\ package,\\ but\\ they\\ are\\ the\\ same\\ project\\ \\(normalized\\ name:\\ my\\-pkg\\)\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Two requirement entries use different spellings of the same project name (hyphen vs underscore, case), which pip normalizes to one name and then sees as a self-conflict.",
  "root_cause_type": "generic",
  "root_cause_zh": "两个需求条目使用同一项目名称的不同拼写（连字符与下划线、大小写），pip 将它们规范化为一个名称后视为自冲突。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Installs the same project twice, with one overwriting the other's files.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "If both names appear in requirements, the conflict recurs on the next install.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "# Replace underscores with hyphens and lowercase everything\nsed -i 's/my_pkg/my-pkg/g' requirements.txt\npython -m pip install -r requirements.txt",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "python - <<'PY'\nfrom packaging.utils import canonicalize_name\nfor n in ['my_pkg', 'My-Pkg', 'my.pkg']:\n    print(n, '->', canonicalize_name(n))\nPY",
      "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.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-19",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}