# 错误：异常：
回溯（最近一次调用最后）：
  文件 "/usr/lib/python3/dist-packages/pip/_internal/req/req_file.py"，第 84 行，在 parse_requirements 中
    line = line.decode('utf-8')
UnicodeDecodeError：'utf-8' 编解码器无法解码位置 0 中的字节 0xff：无效起始字节

- **ID:** `python/pip-unicode-decode-error-requirements`
- **领域:** python
- **类别:** encoding_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

需求文件不是 UTF-8 编码，通常由于 Windows 工具保存为 UTF-16 或 Latin-1。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   Convert the file to UTF-8: `iconv -f UTF-16 -t UTF-8 requirements.txt > requirements_utf8.txt`.
   ```
2. **** (95% 成功率)
   ```
   In a text editor, save as UTF-8 without BOM.
   ```

## 无效尝试

- **** — Loses content; may not fix encoding if the tool saves in wrong format again. (70% 失败率)
- **** — Still reads the file and fails on encoding. (90% 失败率)
