{
  "id": "python/packaging-version-comparison-error",
  "signature": "TypeError: '>' not supported between instances of 'Version' and 'str'",
  "signature_zh": "TypeError：'>' 不支持 'Version' 和 'str' 实例之间",
  "regex": "TypeError:\\ '>'\\ not\\ supported\\ between\\ instances\\ of\\ 'Version'\\ and\\ 'str'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Comparing a packaging.version.Version object directly with a string without conversion.",
  "root_cause_type": "generic",
  "root_cause_zh": "直接将 packaging.version.Version 对象与字符串进行比较而未进行转换。",
  "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": "String comparison of versions (e.g., '1.10' > '1.9') is lexicographic and incorrect.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Equality may work but other comparisons still fail.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "from packaging.version import Version; v1 = Version('1.0'); v2 = Version('2.0'); print(v1 < v2)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "from packaging.version import parse; print(parse('1.0') > parse('2.0'))",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-12-03",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}