{
  "id": "python/sqlalchemy-missing-driver",
  "signature": "ModuleNotFoundError: No module named 'psycopg2'",
  "signature_zh": "ModuleNotFoundError: 没有名为 'psycopg2' 的模块",
  "regex": "ModuleNotFoundError:\\ No\\ module\\ named\\ 'psycopg2'",
  "domain": "python",
  "category": "install_error",
  "subcategory": null,
  "root_cause": "The database driver for PostgreSQL is not installed in the Python environment.",
  "root_cause_type": "generic",
  "root_cause_zh": "Python 环境中未安装 PostgreSQL 数据库驱动程序。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Installing a different driver without changing the connection string",
      "why_fails": "The connection string still references psycopg2.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using a virtual environment without activating it",
      "why_fails": "The module is installed but not accessible.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Install psycopg2 using pip",
      "success_rate": 0.95,
      "how": "pip install psycopg2-binary",
      "condition": "",
      "sources": []
    },
    {
      "action": "Switch to a different driver like asyncpg",
      "success_rate": 0.85,
      "how": "# Change connection string to use asyncpg\nengine = create_engine('postgresql+asyncpg://user:pass@localhost/db')",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-08-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}