# 类型错误：'str' 对象不可迭代
  位于 setup(install_requires='requests')

- **ID:** `python/setuptools-install-requires-string-not-list`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

setup() 向 install_requires（或 extras_require）传入字符串而非列表。setuptools 会逐字符迭代该值，导致失败或安装无意义的内容。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (98% 成功率)
   ```
   setup(
    name='mypkg',
    install_requires=['requests>=2.31', 'click>=8'],
)
   ```
2. **** (90% 成功率)
   ```
   from pathlib import Path
reqs = [l.strip() for l in Path('requirements.txt').read_text().splitlines() if l.strip() and not l.startswith('#')]
setup(install_requires=reqs)
   ```

## 无效尝试

- **** — The bug is in your setup.py, not setuptools. (90% 失败率)
- **** — Still a string; setuptools still iterates characters. (95% 失败率)
- **** — Doesn't change the type mismatch in setup(). (85% 失败率)
