python
encoding_error
ai_generated
partial
UnicodeDecodeError: 'ascii' 编解码器无法解码位置 42 的字节 0xe2:序数不在范围(128)内
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 42: ordinal not in range(128)
ID: python/pip-unicode-decode-error-in-metadata
80%修复率
82%置信度
0证据数
2024-12-01首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.7 | active | — | — | — |
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
根因分析
包的元数据文件(如 PKG-INFO、setup.py)包含非 ASCII 字符,但没有正确的编码声明。pip 的元数据解析器在某些环境中默认使用 ASCII。
English
A package's metadata file (e.g., PKG-INFO, setup.py) contains non-ASCII characters without proper encoding declaration. pip's metadata parser defaults to ASCII in some environments.
解决方案
-
75% 成功率
Download the package source, edit the metadata file to add an encoding declaration (e.g., # -*- coding: utf-8 -*-), and install locally.
-
70% 成功率
Report the issue to the package maintainer; meanwhile, try installing an older version that may not have the problematic characters.
无效尝试
常见但无效的做法:
-
80% 失败
Affects I/O encoding, not the encoding used when reading package files.
-
90% 失败
The issue is in the package's metadata, not pip.