{
  "id": "python/setuptools-install-requires-string-not-list",
  "signature": "TypeError: 'str' object is not iterable\n  in setup(install_requires='requests')",
  "signature_zh": "类型错误：'str' 对象不可迭代\n  位于 setup(install_requires='requests')",
  "regex": "TypeError:\\ 'str'\\ object\\ is\\ not\\ iterable\\\n\\ \\ in\\ setup\\(install_requires='requests'\\)",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "setup() passes a string instead of a list to install_requires (or extras_require). setuptools iterates the value character-by-character and fails or installs nonsense.",
  "root_cause_type": "generic",
  "root_cause_zh": "setup() 向 install_requires（或 extras_require）传入字符串而非列表。setuptools 会逐字符迭代该值，导致失败或安装无意义的内容。",
  "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": "The bug is in your setup.py, not setuptools.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Still a string; setuptools still iterates characters.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Doesn't change the type mismatch in setup().",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.98,
      "how": "setup(\n    name='mypkg',\n    install_requires=['requests>=2.31', 'click>=8'],\n)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "from pathlib import Path\nreqs = [l.strip() for l in Path('requirements.txt').read_text().splitlines() if l.strip() and not l.startswith('#')]\nsetup(install_requires=reqs)",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}