{
  "id": "python/flask-importerror-cannot-import-name-current-app",
  "signature": "ImportError: cannot import name 'current_app' from 'flask'",
  "signature_zh": "ImportError: 无法从 'flask' 导入名称 'current_app'",
  "regex": "ImportError:\\ cannot\\ import\\ name\\ 'current_app'\\ from\\ 'flask'",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "Attempting to import current_app from flask, but it's not a top-level import; it's part of flask.globals.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试从 flask 导入 current_app，但它不是顶级导入；它是 flask.globals 的一部分。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using 'from flask import current_app' incorrectly in a script.",
      "why_fails": "current_app is available only within a request context; importing it outside causes ImportError.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Typo: using 'currentapp' instead of 'current_app'.",
      "why_fails": "The exact name is 'current_app'; any typo leads to ImportError.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Import current_app from flask.globals.",
      "success_rate": 0.9,
      "how": "from flask.globals import current_app",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use app.app_context() to access current_app.",
      "success_rate": 0.85,
      "how": "with app.app_context():\n    from flask import current_app\n    # use current_app",
      "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.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}