python
config_error
ai_generated
true
error: package directory 'src/mypkg' does not exist
ID: python/setuptools-package-dir-and-packages-conflict
80%Fix Rate
88%Confidence
0Evidence
2024-06-25First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
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.
generic中文
setup.py 声明了 packages=['mypkg'] 和 package_dir={'':'src'},但 src/mypkg 目录缺失或命名不同。常见于搭建 src 布局项目时忘记创建包文件夹。
Workarounds
-
98% success
mkdir -p src/mypkg && touch src/mypkg/__init__.py
-
95% success
from setuptools import setup, find_packages; setup(packages=find_packages(where='src'), package_dir={'':'src'}) -
92% success
[tool.setuptools.packages.find]\nwhere = ["src"]
Dead Ends
Common approaches that don't work:
-
90% fail
Build isolation is not the issue; the source tree is malformed.
-
70% fail
find_packages() defaults to where='.' and will not find packages under src/.