python config_error ai_generated true

错误:包目录'src/mypackage'不存在

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

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

其他格式: JSON · Markdown 中文 · English
80%修复率
85%置信度
0证据数
2024-05-12首次发现

版本兼容性

版本状态引入弃用备注
3.8 active

根因分析

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

English

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

generic

解决方案

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

无效尝试

常见但无效的做法:

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

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

  2. Removing package_dir entirely 60% 失败

    Breaks package discovery; setuptools may look in wrong place.