警告:锁定文件不是最新的 pyproject.toml 中的最新更改

mar*_*use 4 python python-poetry

当我在 Python 3.7 中使用诗歌命令时,就我而言:

poetry export -f requirements.txt
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

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.
Run Code Online (Sandbox Code Playgroud)

到目前为止很清楚,但如果我运行诗歌更新,它会升级我的依赖项,这不是我目前想要的项目。如果我改为运行诗歌锁,它仍然会升级依赖项。

我该如何解决这个问题?

mar*_*use 15

这是一个已知问题Poetry 中的。

当前的解决方法是使用以下命令:

poetry add pathlib2
poetry remove pathlib2
Run Code Online (Sandbox Code Playgroud)

其中 pathlib2 是您尚未依赖的任何库,并且不依赖于它自己的库,因此是 pathlib2。

使用这些命令将重写锁定文件哈希并解决文件冲突,而无需升级项目中使用的任何其他包。

  • Poetry 现在有一个“poetry lock --no-update”命令,可以产生相同的结果。在链接的 Github 问题中提到了这一点,您可能需要更新您的答案@marcuse (4认同)