我们有一个带有 pyproject.toml 文件的诗歌项目,如下所示:
[tool.poetry]
name = "daisy"
version = "0.0.2"
description = ""
authors = [""]
[tool.poetry.dependencies]
python = "^3.9"
pandas = "^1.5.2"
DateTime = "^4.9"
names = "^0.3.0"
uuid = "^1.30"
pyyaml = "^6.0"
psycopg2-binary = "^2.9.5"
sqlalchemy = "^2.0.1"
pytest = "^7.2.0"
[tool.poetry.dev-dependencies]
jupyterlab = "^3.5.2"
line_profiler = "^4.0.2"
matplotlib = "^3.6.2"
seaborn = "^0.12.1"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
当我更改文件以使用 Python 3.11 并运行
poetry update
时,我们收到以下错误:
Current Python version (3.9.7) is not allowed by the project (^3.11).
Please change python executable via the "env use" command.
我只有一个环境:
> poetry env list
daisy-Z0c0FuMJ-py3.9 (Activated)
奇怪的是,这个问题不会出现在我的 Macbook 上,只出现在我们的 Linux 机器上。
Poetry 无法更新现有 venv 的 Python 版本。删除现有的并再次运行
poetry install
。
您需要做一些事情。
首先摆脱旧的虚拟环境:
poetry env remove old-environment
rm poetry.lock
更新
pyproject.toml
以使用您想要使用的Python版本:python = "^3.11"
,就你而言。
将 Poetry 参考新的 Python 可执行文件:
poetry env use path-to-the-new-python-3.11
重建您的虚拟环境:
poetry install
这将链接到 Python 3.11 并在新的虚拟环境中安装所有依赖项。