# UnicodeDecodeError: 'charmap' codec can't decode byte 0x9a in position 1234: character maps to <undefined>

- **ID:** `python/pip-requirements-file-encoding-error`
- **Domain:** python
- **Category:** encoding_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A requirements.txt file contains non-UTF-8 encoded characters (e.g., Windows-1252), and pip attempts to decode it using the system's default encoding.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |

## Workarounds

1. **Re-save requirements.txt with UTF-8 encoding using a proper editor** (95% success)
   ```
   Open file in VS Code or Sublime, click 'Save with Encoding' and choose UTF-8, then re-run `pip install -r requirements.txt`
   ```
2. **Force pip to use UTF-8 encoding by setting PYTHONUTF8 environment variable** (85% success)
   ```
   On Windows: `set PYTHONUTF8=1` then `pip install -r requirements.txt`. On Linux/macOS: `PYTHONUTF8=1 pip install -r requirements.txt`
   ```

## Dead Ends

- **Manually editing the file in Notepad and saving as ANSI** — Notepad's 'ANSI' encoding is often Windows-1252, which may still contain problematic bytes for other locales. (70% fail)
- **Using `pip install -r requirements.txt --no-cache`** — The --no-cache flag does not affect file decoding; the error occurs during file reading, not caching. (90% fail)
