Python Poetry:找不到包的测试版

Python Poetry: Cannot find beta versions of a package

我正在尝试使用 SQLAlchemy 1.4 beta with Poetry. It is released on PyPi

诗歌无法识别pyproject.toml中的测试包:

[tool.poetry.dependencies]
SQLAlchemy = "^1.4.0b3"
poetry install
Installing dependencies from lock file

Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them.

  SolverProblemError

  Because ...  depends on SQLAlchemy (1.4.0b3) which doesn't match any versions, version solving failed.

如何让 Poetry 获取包的测试版?

在您的 pyproject.toml 中,您需要以详细的形式指定此依赖项(可以找到更多相关信息 here):

SQLAlchemy = {version = "^1.4.0b3"}

然后将选项 allow-prereleases 设置为 true,这样您的代码看起来像

SQLAlchemy = {version = "^1.4.0b3", allow-prereleases = true}

或者,您可以使用 CLI 使用相应的选项添加此依赖项:

poetry add SQLAlchemy@^1.4.0b3 --allow-prereleases

您还可以这样做:

SQLAlchemy = {version = "^1.4.0*", allow-prereleases = true}