{
  "id": "python/pytest-doctest-import-error",
  "signature": "Failed: [doctest] mymodule.func\nUNEXPECTED EXCEPTION: ModuleNotFoundError: No module named 'mymodule'",
  "signature_zh": "Failed: [doctest] mymodule.func\n意外异常: ModuleNotFoundError: 没有名为 'mymodule' 的模块",
  "regex": "Failed:\\ \\[doctest\\]\\ mymodule\\.func\\\nUNEXPECTED\\ EXCEPTION:\\ ModuleNotFoundError:\\ No\\ module\\ named\\ 'mymodule'",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "pytest-doctest tries to import the module from the doctest file, but the module is not on sys.path because tests run from a different directory.",
  "root_cause_type": "generic",
  "root_cause_zh": "pytest-doctest 尝试从 doctest 文件导入模块，但模块不在 sys.path 上，因为测试从不同目录运行。",
  "versions": [
    {
      "version": "7.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "May work locally but fails in CI where the working directory differs.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Loses doctest coverage; not a fix.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "pip install -e .\npytest --doctest-modules",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "In pytest.ini: `[pytest]\npythonpath = .`",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-10-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}