python data_error ai_generated true

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

ID: python/setuptools-invalid-package-name

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.6 active
3.7 active
3.8 active

Root Cause

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

generic

中文

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

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 90% fail

    Setuptools will reject it.

  2. 30% fail

    Must also update the name in setup.py.