将 pyproject.toml 添加到项目会使 pip 安装失败
Adding pyproject.toml to project makes pip install fail
我正在使用 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/
为什么会出现此错误,我该如何解决?
根据 this GitHub issue 中的讨论,要解决此问题,您需要 运行 pip3 install -e . --user --no-use-pep517
。
原因很复杂,但本质上是:
通过使用 pyproject.toml
,您向 pip
表明您应该使用新的 pep517
安装过程。
pep517
不支持-e
或--user
,所以失败。
没有其他方法可以自动配置 black
,因此您只能使用 pyproject.toml
和 --no-use-pep517
。
我正在使用 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/
为什么会出现此错误,我该如何解决?
根据 this GitHub issue 中的讨论,要解决此问题,您需要 运行 pip3 install -e . --user --no-use-pep517
。
原因很复杂,但本质上是:
通过使用
pyproject.toml
,您向pip
表明您应该使用新的pep517
安装过程。pep517
不支持-e
或--user
,所以失败。没有其他方法可以自动配置
black
,因此您只能使用pyproject.toml
和--no-use-pep517
。