# UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

- **ID:** `python/pip-freeze-unicode-decode-error`
- **Domain:** python
- **Category:** encoding_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A site-packages .dist-info METADATA or RECORD file was written with a non-UTF-8 encoding (often cp1252 or UTF-16 on Windows), and pip freeze/install tries to read it as UTF-8.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   python - <<'PY'
import pathlib, sys
for p in pathlib.Path(sys.prefix).rglob('METADATA'):
    try:
        p.read_text(encoding='utf-8')
    except UnicodeDecodeError:
        print('BAD:', p)
PY
# then uninstall the owning package
python -m pip uninstall -y badpkg
   ```
2. **** (85% success)
   ```
   python -m pip install --force-reinstall --no-cache-dir badpkg
   ```

## Dead Ends

- **** — Affects stdout/stderr only, not the file-reading path that raises the error. (85% fail)
- **** — The corrupt file belongs to another package's metadata, not pip itself. (90% fail)
