{
  "id": "python/pip-install-error-permission-denied",
  "signature": "ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/usr/local/lib/python3.9/site-packages/package'",
  "signature_zh": "错误：由于 OSError：[Errno 13] 权限被拒绝：'/usr/local/lib/python3.9/site-packages/package'，无法安装包",
  "regex": "ERROR:\\ Could\\ not\\ install\\ packages\\ due\\ to\\ an\\ OSError:\\ \\[Errno\\ 13\\]\\ Permission\\ denied:\\ '/usr/local/lib/python3\\.9/site\\-packages/package'",
  "domain": "python",
  "category": "system_error",
  "subcategory": null,
  "root_cause": "pip lacks write permissions to the target site-packages directory, typically because it is owned by root or another user.",
  "root_cause_type": "generic",
  "root_cause_zh": "pip 缺少对目标 site-packages 目录的写入权限，通常是因为该目录属于 root 或其他用户。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This can work but may cause permission issues later and is not recommended for user environments.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Reinstalling Python does not change directory ownership.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This may work but can lead to conflicts with system packages.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "pip install --user package",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.98,
      "how": "python3 -m venv myenv && source myenv/bin/activate && pip install package",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.7,
      "how": "sudo chown -R $USER /usr/local/lib/python3.9/site-packages",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}