python type_error ai_generated true

TypeError:entry_points() 得到了意外的关键字参数 'console_scripts'

TypeError: entry_points() got an unexpected keyword argument 'console_scripts'

ID: python/setuptools-entry-points-error

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

版本兼容性

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

根因分析

在 setup.py 中错误使用 entry_points 参数;console_scripts 应该是字典中的一个键,而不是单独的参数。

English

Incorrect use of entry_points parameter in setup.py; console_scripts should be a key in a dictionary, not a separate argument.

generic

解决方案

  1. 95% 成功率 Correctly structure entry_points as a dictionary
    `setup(..., entry_points={'console_scripts': ['mycmd=mymodule:main']})`
  2. 90% 成功率 Use pyproject.toml with [project.scripts] instead
    In pyproject.toml: `[project.scripts]
    mycmd = "mymodule:main"`

无效尝试

常见但无效的做法:

  1. Passing console_scripts as a list directly to setup() 70% 失败

    setup() expects entry_points as a dict; console_scripts is not a valid top-level parameter.

  2. Removing entry_points entirely 50% 失败

    This removes the command-line scripts, which may be required for the package's functionality.