python data_error ai_generated true

FileNotFoundError:[Errno 2] 没有这样的文件或目录:sdist 安装期间 'mypkg/data/config.yaml'

FileNotFoundError: [Errno 2] No such file or directory: 'mypkg/data/config.yaml' during sdist install

ID: python/setuptools-manifest-in-missing-sdist-files

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

版本兼容性

版本状态引入弃用备注
3.8 active — — —
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

根因分析

MANIFEST.in 未将数据文件包含在 sdist 中,因此安装的包缺少该文件。错误在运行时尝试打开文件时出现。

English

MANIFEST.in did not include the data file in the sdist, so the installed package is missing it. The error surfaces at runtime when the code tries to open the file.

generic

解决方案

  1. 95% 成功率
    echo 'recursive-include mypkg/data *.yaml' >> MANIFEST.in
  2. 97% 成功率
    [tool.setuptools.package-data]\nmypkg = ["data/*.yaml"]
  3. 90% 成功率
    python -m build --sdist && tar -tzf dist/*.tar.gz | grep config.yaml

无效尝试

常见但无效的做法:

  1. 90% 失败

    Reinstalling the same incomplete sdist produces the same result.

  2. 60% 失败

    Not reproducible; breaks on the next install.