# ERROR: Invalid requirement: '﻿package==1.0' (line 1 of requirements.txt)

- **ID:** `pip/requirements-file-bom`
- **Domain:** pip
- **Category:** config_error
- **Error Code:** `ERROR`
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

The requirements.txt file contains a UTF-8 BOM (Byte Order Mark) character at the beginning, which pip's parser does not strip, causing the first line to be interpreted as an invalid package name.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| pip 23.2 | active | — | — |
| pip 24.0 | active | — | — |
| Python 3.9 | active | — | — |
| Python 3.10 | active | — | — |
| Python 3.11 | active | — | — |

## Workarounds

1. **Remove the BOM using a command-line tool: sed -i '1s/^\xef\xbb\xbf//' requirements.txt (Linux/macOS) or use PowerShell: (Get-Content requirements.txt) | Set-Content -Encoding UTF8NoBOM requirements.txt (Windows). Then retry pip install -r requirements.txt.** (95% success)
   ```
   Remove the BOM using a command-line tool: sed -i '1s/^\xef\xbb\xbf//' requirements.txt (Linux/macOS) or use PowerShell: (Get-Content requirements.txt) | Set-Content -Encoding UTF8NoBOM requirements.txt (Windows). Then retry pip install -r requirements.txt.
   ```
2. **Recreate the requirements file without BOM: echo 'package==1.0' > requirements.txt && cat old_requirements.txt | tail -n +2 >> requirements.txt (skip first line with BOM).** (92% success)
   ```
   Recreate the requirements file without BOM: echo 'package==1.0' > requirements.txt && cat old_requirements.txt | tail -n +2 >> requirements.txt (skip first line with BOM).
   ```
3. **Convert the file encoding using a Python script: python -c "with open('requirements.txt', 'r', encoding='utf-8-sig') as f: content = f.read(); with open('requirements.txt', 'w', encoding='utf-8') as f: f.write(content)" && pip install -r requirements.txt** (97% success)
   ```
   Convert the file encoding using a Python script: python -c "with open('requirements.txt', 'r', encoding='utf-8-sig') as f: content = f.read(); with open('requirements.txt', 'w', encoding='utf-8') as f: f.write(content)" && pip install -r requirements.txt
   ```

## Dead Ends

- **** — Adding --no-cache-dir does not fix the BOM character in the file; it only affects pip's cache behavior. (98% fail)
- **** — Using pip install --upgrade pip does not change the file encoding; BOM remains. (95% fail)
- **** — Editing the file manually in a text editor may not remove the BOM if the editor adds it back (e.g., Notepad on Windows). (60% fail)
