{
  "id": "python/flask-import-error-flask-sqlalchemy-not-installed",
  "signature": "ImportError: No module named 'flask_sqlalchemy'",
  "signature_zh": "ImportError: 没有名为 'flask_sqlalchemy' 的模块",
  "regex": "ImportError:\\ No\\ module\\ named\\ 'flask_sqlalchemy'",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "Flask-SQLAlchemy extension is not installed in the environment.",
  "root_cause_type": "generic",
  "root_cause_zh": "环境中未安装 Flask-SQLAlchemy 扩展。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Installing with pip install flask-sqlalchemy but using wrong import name",
      "why_fails": "Import name is flask_sqlalchemy, not flask-sqlalchemy.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Assuming it's included with Flask",
      "why_fails": "Flask-SQLAlchemy is a separate package.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Install Flask-SQLAlchemy",
      "success_rate": 0.95,
      "how": "pip install flask-sqlalchemy\n# Then import: from flask_sqlalchemy import SQLAlchemy",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use virtual environment and install",
      "success_rate": 0.9,
      "how": "python -m venv venv\nsource venv/bin/activate\npip install flask flask-sqlalchemy",
      "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-02-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}