【问题标题】:Adding pyproject.toml to project makes pip install fail将 pyproject.toml 添加到项目中会使 pip install 失败
【发布时间】:2020-02-04 20:25:13
【问题描述】:

我正在使用pyproject.toml 来配置black。但是,当添加此文件时,pip3 install -e . --user 失败并出现以下错误:

    ERROR: Complete output from command /usr/bin/python3 -c 'import setuptools, tokenize;__file__='"'"'/home/sean/git/auto-md/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix=:
    ERROR: usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help

    error: option --user not recognized
    ----------------------------------------
ERROR: Command "/usr/bin/python3 -c 'import setuptools, tokenize;__file__='"'"'/home/sean/git/auto-md/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix=" failed with error code 1 in /home/sean/git/auto-md/

为什么会出现这个错误,我该如何解决?

【问题讨论】:

    标签: python pip pyproject.toml


    【解决方案1】:

    根据this GitHub issue中的讨论,要解决这个问题,你需要运行pip3 install -e . --user --no-use-pep517

    原因很复杂,但本质上是:

    1. 通过使用pyproject.toml,您向pip 表明您应该使用新的pep517 安装过程。

    2. pep517 不支持-e--user,所以会失败。

    3. 没有其他方法可以自动配置black,因此您只能使用pyproject.toml--no-use-pep517

    【讨论】:

      猜你喜欢
      • 2015-12-22
      • 2012-09-24
      • 2018-10-11
      • 2015-05-05
      • 2021-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多