python data_error ai_generated true

错误:无效的包名 'my_pkg'(不允许使用连字符)

error: invalid package name 'my_pkg' (hyphens are not allowed)

ID: python/setuptools-invalid-package-name

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

版本兼容性

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

根因分析

包名包含连字符,Python 包名不允许使用连字符;需要使用下划线或字母数字字符。

English

The package name contains hyphens, which are not allowed in Python package names; underscores or alphanumeric characters are required.

generic

解决方案

  1. 95% 成功率
    In setup.py: name='my_pkg'
  2. 90% 成功率
    setup(name='my-pkg', packages=['my_pkg'])

无效尝试

常见但无效的做法:

  1. 90% 失败

    Setuptools will reject it.

  2. 30% 失败

    Must also update the name in setup.py.