{
  "id": "python/pytest-doctest-missing-module",
  "signature": "ERROR collecting doctests\nFile \"...\", line 1, in <module>\nModuleNotFoundError: No module named 'myapp'",
  "signature_zh": "收集 doctests 时出错\nFile \"...\", line 1, in <module>\nModuleNotFoundError: 没有名为 'myapp' 的模块",
  "regex": "ERROR\\ collecting\\ doctests\\\nFile\\ \"\\.\\.\\.\",\\ line\\ 1,\\ in\\ <module>\\\nModuleNotFoundError:\\ No\\ module\\ named\\ 'myapp'",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "pytest --doctest-modules discovers .py files under the project tree, including examples/ or docs/ that import the package, but the package is not installed or on sys.path.",
  "root_cause_type": "generic",
  "root_cause_zh": "pytest --doctest-modules 发现项目树下的 .py 文件（包括 examples/ 或 docs/），这些文件导入包但包未安装或不在 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": "Skips real doctests in examples; other directories still fail if the package is not importable.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Boilerplate in every file; breaks when run from a different cwd.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "pip install -e .\npytest --doctest-modules src/myapp -q",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "# pyproject.toml\n[tool.pytest.ini_options]\ntestpaths = ['src/myapp', 'tests']\npythonpath = ['src']\naddopts = '--doctest-modules'",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-05-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}