python config_error ai_generated true

error: package directory 'src/mypackage' does not exist

ID: python/setuptools-package-dir-not-found

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2024-05-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active

Root Cause

The directory specified in 'packages' or 'package_dir' does not exist on disk.

generic

中文

在'packages'或'package_dir'中指定的目录在磁盘上不存在。

Workarounds

  1. 95% success Create the missing directory with __init__.py
    mkdir -p src/mypackage
    touch src/mypackage/__init__.py
  2. 90% success Update setup.py to match existing structure
    from setuptools import find_packages
    setup(
        packages=find_packages(where='src'),
        package_dir={'': 'src'}
    )

Dead Ends

Common approaches that don't work:

  1. Creating a placeholder __init__.py in wrong location 80% fail

    The directory structure must match exactly; wrong location doesn't fix.

  2. Removing package_dir entirely 60% fail

    Breaks package discovery; setuptools may look in wrong place.