python-3.x - 如何解决 Python 诗歌依赖错误
问题描述
尝试使用 Poetry 安装 Python 依赖项时,出现以下错误:
$ poetry install
The currently activated Python version 2.7.15 is not supported by the project (>=3.6).
Trying to find and use a compatible version.
Using python3 (3.7.4)
Skipping virtualenv creation, as specified in config file.
Updating dependencies
Resolving dependencies... (1.7s)
[SolverProblemError]
The current project's Python requirement (>=3.6) is not compatible with some of the required packages Python requirement:
- pre-commit requires Python >=3.6.1
Because no versions of pre-commit match >2.2.0,<3.0.0
and pre-commit (2.2.0) requires Python >=3.6.1, pre-commit is forbidden.
So, because my-proj depends on pre-commit (^2.2.0), version solving failed.
这是我的环境:
$ python3 --version
Python 3.7.4
$ poetry --version
Poetry version 1.0.5
$ pre-commit --version
pre-commit 2.2.0
还有我的 pyproject.toml 示例:
...
[tool.poetry.dependencies]
python = ">=3.6"
...
[tool.poetry.dev-dependencies]
pre-commit = "^2.2.0"
...
我尝试将 pyproject 中的 python 版本更改为 3.7,但没有更改结果。如果我删除了 pre-commit 依赖项,我会在另一个依赖项上遇到同样的错误。
我不知道我应该寻找什么:升级/降级版本,不兼容的版本
解决方案
正如@Arne 在评论中提到的那样,这似乎是一个 virtualenv 问题。
我poetry config virtualenvs.create false
之前为另一个项目运行过,并且配置是在全局级别设置的。运行反向命令poetry config virtualenvs.create true
解决了问题(可能添加--local
以将其设置为单个项目)。
推荐阅读
- cordova - Cordova 和 iOS:配置方案和主机名以显示本地图像
- docker - Prometheus & Nifi Exporter - 服务器返回 HTTP 状态 500 内部服务器错误
- html - 内容安全策略 - 外部 HTML
- django - request.user 即使用户登录也返回 AnonymousUser
- c - xv6 看不懂这行代码
- node.js - 更新包含图像的表单 - NodeJS
- javascript - body 溢出-y:隐藏,同时保留滚动位置
- flutter - 'RenderObject?' 类型的值 不能分配给“RenderRepaintBoundary”类型的变量
- huggingface-transformers - HuggingFace AttributeError:“str”对象没有属性“to”
- python - 在将时间序列数据转换为其频域时,如何选择要使用的正确频率?