# 错误：子进程以错误退出：python setup.py egg_info 未成功运行。
  退出代码：1
  __main__.NameError: 名称 'unicode' 未定义

- **ID:** `pip/egg-info-failure-setup-py-encoding`
- **领域:** pip
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

包的 setup.py 使用了 Python 2 风格的 'unicode' 内置函数，该函数在 Python 3 中被移除，导致 egg_info 生成失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| pip 23.1 | active | — | — |
| Python 3.10 | active | — | — |
| setuptools 58.0 | active | — | — |

## 解决方案

1. ```
   在 setup.py 中应用猴子补丁，添加 'import six' 或将 'unicode' 替换为 'str'，然后使用 pip install --no-build-isolation <package> 安装。
   ```
2. ```
   安装支持 Python 3 的旧版本包：pip install <package>==<last_py3_compatible_version>
   ```
3. ```
   在 Python 2.7 环境中构建包并安装生成的 wheel：python2 -m pip wheel <package> 然后 pip install <package>.whl
   ```

## 无效尝试

- **** — Running pip install --no-cache-dir does not fix the root cause; the setup.py is still broken. (95% 失败率)
- **** — Upgrading pip alone does not patch the package's broken setup.py; the NameError persists. (90% 失败率)
- **** — Using --use-pep517 may switch to a different build system, but if the package lacks pyproject.toml, it falls back to setup.py and fails again. (80% 失败率)
