{
  "id": "python/setuptools-package-dir-and-packages-conflict",
  "signature": "error: package directory 'src/mypkg' does not exist",
  "signature_zh": "错误：包目录 'src/mypkg' 不存在",
  "regex": "error:\\ package\\ directory\\ 'src/mypkg'\\ does\\ not\\ exist",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "setup.py declares packages=['mypkg'] and package_dir={'':'src'} but the src/mypkg directory is missing or named differently. Common when scaffolding a src-layout project and forgetting to create the package folder.",
  "root_cause_type": "generic",
  "root_cause_zh": "setup.py 声明了 packages=['mypkg'] 和 package_dir={'':'src'}，但 src/mypkg 目录缺失或命名不同。常见于搭建 src 布局项目时忘记创建包文件夹。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Build isolation is not the issue; the source tree is malformed.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "find_packages() defaults to where='.' and will not find packages under src/.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.98,
      "how": "mkdir -p src/mypkg && touch src/mypkg/__init__.py",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "from setuptools import setup, find_packages; setup(packages=find_packages(where='src'), package_dir={'':'src'})",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "[tool.setuptools.packages.find]\\nwhere = [\"src\"]",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-25",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}