根据 poetry 文档,设置新项目的正确方法是使用
poetry new poetry-demo
。但是这会创建一个基于已停用的 python 2.7 的项目,并创建以下 toml 文件。[tool.poetry]
name = "poetry-demo"
version = "0.1.0"
description = ""
authors = ["Harsha Goli <harshagoli@gmail.com>"]
[tool.poetry.dependencies]
python = "^2.7"
[tool.poetry.dev-dependencies]
pytest = "^4.6"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
我该如何将它更新到3.7?只需将 python = "^2.7"
更改为 python = "^3.7"
即可。但是,运行 poetry install
后会出现以下错误:[SolverProblemError]
The current project's Python requirement (2.7.17) is not compatible with some of the required packages Python requirement:
- zipp requires Python >=3.6
Because no versions of pytest match >=4.6,<4.6.9 || >4.6.9,<5.0
and pytest (4.6.9) depends on importlib-metadata (>=0.12), pytest (>=4.6,<5.0) requires importlib-metadata (>=0.12).
And because no versions of importlib-metadata match >=0.12,<1.5.0 || >1.5.0
and importlib-metadata (1.5.0) depends on zipp (>=0.5), pytest (>=4.6,<5.0) requires zipp (>=0.5).
Because zipp (3.1.0) requires Python >=3.6
and no versions of zipp match >=0.5,<3.1.0 || >3.1.0, zipp is forbidden.
Thus, pytest is forbidden.
So, because poetry-demo depends on pytest (^4.6), version solving failed.
poetry new poetry-demo
,而不是3。 - Thomas