python config_error ai_generated true

ERROR: setuptools.errors.PackageDiscoveryError: Multiple top-level packages discovered in a flat-layout: ['mypackage', 'mypackage2']

ID: python/setuptools-package-dir-conflict

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.9 active
3.10 active

Root Cause

Setuptools auto-discovery finds multiple packages in the root directory, causing ambiguity.

generic

中文

Setuptools 自动发现功能在根目录中找到多个包,导致歧义。

Workarounds

  1. 95% success Explicitly specify packages in setup.cfg or setup.py
    In setup.cfg: [options]
    packages = find:
    find:
    include = mypackage*
    Or in setup.py: packages=['mypackage']
  2. 85% success Use namespace packages if both are related
    Rename packages to share a namespace like 'company.mypackage' and 'company.mypackage2'.

Dead Ends

Common approaches that don't work:

  1. Renaming one package to a subpackage 70% fail

    Does not resolve the discovery conflict; setuptools still sees two top-level packages.

  2. Removing one package directory entirely 50% fail

    Loss of code; better to configure explicitly.