英文:
poetry add using a caret and a @ symbol
问题
I am confused as to what the "@" operator actually does in poetry add pandas@^1.3.0
.
Both following commands install pandas version 1.5.3 and set the dependency in my pyproject.toml to pandas = "^1.3.0"
:
poetry add pandas@^1.3.0
poetry add pandas^1.3.0
I have no other dependencies listed (aside from Python 3.8).
I thought that using the "@" symbol signifies a strict requirement for a specific version and its compatible releases. With "pandas@^1.3.0," shouldn't Poetry install exactly the version 1.3.0 of the "pandas" package?
The official documentation says:
When adding dependencies via poetry add, you can use the @ operator.
This is understood similarly to the == syntax, but also allows
prefixing any specifiers that are valid in pyproject.toml. For
example:
英文:
I am confused as to what the "@" operator actually does in poetry add pandas@^1.3.0
.
Both following commands install pandas version 1.5.3 and set the dependency in my pyproject.toml to pandas = "^1.3.0"
:
poetry add pandas@^1.3.0
poetry add pandas^1.3.0
I have no other dependencies listed (aside from Python 3.8).
I thought that using the "@" symbol signifies a strict requirement for a specific version and its compatible releases. With "pandas@^1.3.0," shouldn't Poetry install exactly the version 1.3.0 of the "pandas" package?
The official documentation says:
> When adding dependencies via poetry add, you can use the @ operator.
> This is understood similarly to the == syntax, but also allows
> prefixing any specifiers that are valid in pyproject.toml. For
> example:
答案1
得分: 2
The "@" operator in the add command is a delimiter between the package name and the version.
If the "@" operator is followed by its required version, e.g.
poetry add pendulum@2.0.5
is the same as:
poetry add pendulum==2.0.5
If you use caret, e.g.:
poetry add requests@^2.13.0
Then you specify a version range.
The "@" symbol signifies a strict requirement only if you don't use any other specifier afterwards. The poetry documentation for "@" operator is a bit confusing.
英文:
The "@" operator in the add command is a delimiter between the package name and the version.
If the "@" operator is followed by its required version, e.g.
poetry add pendulum@2.0.5
is the same as:
poetry add pendulum==2.0.5
If you use caret, e.g.:
poetry add requests@^2.13.0
Then you specify a version range.
The "@" symbol signifies a strict requirement only if you don't use any other specifier afterwards. The poetry documentation for "@" operator is a bit confusing.
答案2
得分: 0
如果意图是固定软件包到特定版本,那么应该使用 "==",这在以下链接中明确说明:https://python-poetry.org/docs/dependency-specification/#exact-requirements
关于你的问题,你尝试的有以下几种方式:
- poetry add pandas@^1.3.0
- poetry add pandas^1.3.0
插入符(^)允许升级到一个稍后的版本,只要它不修改最左边的非零(主要版本)数字。所以即使你写了^1.3.0,它会找到 pandas 主要版本为 1 的最新版本(https://pypi.org/project/pandas/#history),即 1.5.3。
如果你坚持使用 @ 符号,请尝试 "poetry add pandas@1.3.0"。
英文:
If the intention is to pin the package to a specific version, then "==" is what we must be using, and it clearly outlined in : https://python-poetry.org/docs/dependency-specification/#exact-requirements
Coming to your question, what you have attempted are the below:
poetry add pandas@^1.3.0
poetry add pandas^1.3.0
The caret(^) symbol allows upgrades to a later version as long as it doesn't modify the left most non-zero(major version) digit. So even though you say ^1.3.0, it finds the latest version of pandas with major version 1 (https://pypi.org/project/pandas/#history), which is 1.5.3.
If you are keen on using @ ,please do give a try with "poetry add pandas@1.3.0".
答案3
得分: 0
不应该。根据文档,它要求pandas包的最低版本是1.3.0
,最高版本严格小于2.0.0
。参考链接:# 允许>=2.0.5,<3.0.0版本 poetry add pendulum@^2.0.5
英文:
> With "pandas@^1.3.0," shouldn't Poetry install exactly the version 1.3.0 of the "pandas" package?
No. According to the docs it requires that the minimal version is 1.3.0
and the maximal is strictly less than 2.0.0
. Reference:
# Allow >=2.0.5, <3.0.0 versions
poetry add pendulum@^2.0.5
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论