{
  "id": "pip/requirements-file-bom",
  "signature": "ERROR: Invalid requirement: '﻿package==1.0' (line 1 of requirements.txt)",
  "signature_zh": "错误：无效的要求：'﻿package==1.0'（requirements.txt 第 1 行）",
  "regex": "ERROR: Invalid requirement: '\\\\ufeff.*?' \\(line 1 of requirements.txt\\)",
  "domain": "pip",
  "category": "config_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "requirements.txt 文件开头包含 UTF-8 BOM（字节顺序标记）字符，pip 的解析器不会去除该字符，导致第一行被解释为无效的包名。",
  "versions": [
    {
      "version": "pip 23.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "pip 24.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Python 3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Python 3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Python 3.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Adding --no-cache-dir does not fix the BOM character in the file; it only affects pip's cache behavior.",
      "fail_rate": 0.98,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using pip install --upgrade pip does not change the file encoding; BOM remains.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Editing the file manually in a text editor may not remove the BOM if the editor adds it back (e.g., Notepad on Windows).",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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.",
      "success_rate": 0.95,
      "how": "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.",
      "condition": "",
      "sources": []
    },
    {
      "action": "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).",
      "success_rate": 0.92,
      "how": "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).",
      "condition": "",
      "sources": []
    },
    {
      "action": "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",
      "success_rate": 0.97,
      "how": "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",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "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.",
    "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).",
    "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"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://pip.pypa.io/en/stable/reference/requirements-file-format/",
  "official_doc_section": null,
  "error_code": "ERROR",
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2024-01-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}