# error: subprocess-exited-with-error: python setup.py egg_info did not run successfully.
  exit code: 1
  __main__.NameError: name 'unicode' is not defined

- **ID:** `pip/egg-info-failure-setup-py-encoding`
- **Domain:** pip
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Package's setup.py uses Python 2 style 'unicode' built-in, which was removed in Python 3, causing egg_info generation to fail.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| pip 23.1 | active | — | — |
| Python 3.10 | active | — | — |
| setuptools 58.0 | active | — | — |

## Workarounds

1. **Apply monkey-patch in setup.py by adding 'import six' or replacing 'unicode' with 'str' in the package source before installation. Use: pip install --no-build-isolation <package> after patching.** (75% success)
   ```
   Apply monkey-patch in setup.py by adding 'import six' or replacing 'unicode' with 'str' in the package source before installation. Use: pip install --no-build-isolation <package> after patching.
   ```
2. **Install an older compatible version of the package that supports Python 3: pip install <package>==<last_py3_compatible_version>** (85% success)
   ```
   Install an older compatible version of the package that supports Python 3: pip install <package>==<last_py3_compatible_version>
   ```
3. **Build the package in a Python 2.7 environment and install the resulting wheel in Python 3. Use: python2 -m pip wheel <package> then pip install <package>.whl** (70% success)
   ```
   Build the package in a Python 2.7 environment and install the resulting wheel in Python 3. Use: python2 -m pip wheel <package> then pip install <package>.whl
   ```

## Dead Ends

- **** — Running pip install --no-cache-dir does not fix the root cause; the setup.py is still broken. (95% fail)
- **** — Upgrading pip alone does not patch the package's broken setup.py; the NameError persists. (90% fail)
- **** — 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% fail)
