# 错误：无法打开requirements文件：[Errno 22] 无效参数：'requirements.txt'

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

## 根因

requirements文件具有无效编码（例如带BOM的UTF-16）或包含空字节。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.9 | active | — | — |

## 解决方案

1. **Convert file to UTF-8 encoding** (90% 成功率)
   ```
   iconv -f UTF-16 -t UTF-8 requirements.txt > requirements_utf8.txt
mv requirements_utf8.txt requirements.txt
   ```
2. **Recreate requirements file with proper encoding** (85% 成功率)
   ```
   pip freeze > requirements.txt
# Ensure editor saves as UTF-8
   ```

## 无效尝试

- **Creating a new file with same name** — Does not fix encoding issue; may recreate with wrong encoding. (80% 失败率)
- **Using --no-cache-dir** — Cache is irrelevant; file reading fails. (90% 失败率)
