python config_error ai_generated true

错误:无法识别选项 --install-lib 用法:setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] 或:setup.py --help [cmd1 cmd2 ...] 或:setup.py --help-commands 或:setup.py cmd --help

error: option --install-lib not recognized usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help

ID: python/setuptools-unknown-distribution-option

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

版本兼容性

版本状态引入弃用备注
3.x active — — —

根因分析

调用自定义 distutils/setuptools 命令时传入了它未在 user_options 中声明的选项,因此选项解析器拒绝该选项。

English

A custom distutils/setuptools command is invoked with an option it does not declare in user_options, so the option parser rejects it.

generic

解决方案

  1. 95% 成功率
    In the Command subclass, add user_options = [('install-lib=', None, 'target directory')] and handle it in initialize_options/finalize_options.
  2. 90% 成功率
    Move the setting into setup.cfg under [install] install-lib = /path and run python setup.py install.

无效尝试

常见但无效的做法:

  1. 90% 失败

    The command still does not declare the option; order does not matter.

  2. 95% 失败

    Verbosity does not register unknown options.

  3. 95% 失败

    Privilege is unrelated to option parsing.