{
  "id": "python/pytest-collection-import-mismatch-src-layout",
  "signature": "ERROR: found no collectors\nImportError while importing test module 'tests/test_api.py'.\nHint: make sure your test modules/packages have valid Python names.\nModuleNotFoundError: No module named 'myapp'",
  "signature_zh": "ERROR: 未找到收集器\n导入测试模块 'tests/test_api.py' 时出现 ImportError。\n提示：确保测试模块/包的 Python 名称有效。\nModuleNotFoundError: 没有名为 'myapp' 的模块",
  "regex": "ERROR:\\ found\\ no\\ collectors\\\nImportError\\ while\\ importing\\ test\\ module\\ 'tests/test_api\\.py'\\.\\\nHint:\\ make\\ sure\\ your\\ test\\ modules/packages\\ have\\ valid\\ Python\\ names\\.\\\nModuleNotFoundError:\\ No\\ module\\ named\\ 'myapp'",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The project uses a src/ layout and the package is not on sys.path because it has not been installed (pip install -e .) and pytest's rootdir does not include src/.",
  "root_cause_type": "generic",
  "root_cause_zh": "项目使用 src/ 布局，包未安装（未执行 pip install -e .）且 pytest 的 rootdir 不包含 src/，导致包不在 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": "Duplicates boilerplate across files, breaks when tests run from a different cwd, and hides packaging bugs.",
      "fail_rate": 0.55,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Not persisted for CI or other contributors; failures reappear in fresh environments.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "pip install -e .\n# or with pyproject.toml\npip install -e '.[dev]'\npytest -q",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "# pyproject.toml\n[tool.pytest.ini_options]\npythonpath = ['src']\ntestpaths = ['tests']",
      "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.86,
  "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": []
}