如何在 python 3.9 的诗歌中添加数据类要求
how to add dataclasses requirement in poetry for python 3.9
在这里尝试诗歌以保持依赖关系。我似乎无法将数据类放入其中。
这是我的 toml 文件:
[tool.poetry.dependencies]
python = "^3.9"
certifi = "^2020.12.5"
chardet = "^4.0.0"
hivemind-util = "^0.1b35"
idna = "^2.9"
requests = "^2.25.1"
urllib3 = "^1.26.3"
pytest = "^6.2.2"
pandas = "^1.2.3"
pyarrow = "^3.0.0"
numpy = "^1.20.1"
pyodbc = "^4.0.30"
responses = "^0.12.1"
openpyxl = "^3.0.6"
SQLAlchemy = "^1.3.23"
dataclasses-json = "^0.5.2"
当我 运行
poetry add dataclasses
我明白了
SolverProblemError
The current project's Python requirement (>=2.7,<2.8 || >=3.4) is not compatible with some of the required packages Python requirement:
- dataclasses requires Python >=3.6, <3.7, so it will not be satisfied for Python >=2.7,<2.8 || >=3.4,<3.6 || >=3.7
Because no versions of dataclasses match >0.8,<0.9
and dataclasses (0.8) requires Python >=3.6, <3.7, dataclasses is forbidden.
So, because my-project depends on dataclasses (^0.8), version solving failed.
at ~\.poetry\lib\poetry\puzzle\solver.py:241 in _solve
237│ packages = result.packages
238│ except OverrideNeeded as e:
239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240│ except SolveFailure as e:
→ 241│ raise SolverProblemError(e)
242│
243│ results = dict(
244│ depth_first_search(
245│ PackageNode(self._package, packages), aggregate_package_nodes
• Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties
For dataclasses, a possible solution would be to set the `python` property to ">=3.6,<3.7"
https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
https://python-poetry.org/docs/dependency-specification/#using-environment-markers
这里有什么问题?数据类适用于 python 3.9
dataclasses
模块是 python3.7
及更高版本标准库的一部分。如果你也想支持 python3.6
,你只需要安装它(另见 PyPI 上的 the description:“A backport of the dataclasses module for Python 3.6").错误消息也会告诉您这一点,但如果您不是计算机,则以某种方式有点难以理解。
鉴于您的 python 版本似乎是 3.9,您无需执行任何操作 - 您只需使用数据类即可。
在这里尝试诗歌以保持依赖关系。我似乎无法将数据类放入其中。
这是我的 toml 文件:
[tool.poetry.dependencies]
python = "^3.9"
certifi = "^2020.12.5"
chardet = "^4.0.0"
hivemind-util = "^0.1b35"
idna = "^2.9"
requests = "^2.25.1"
urllib3 = "^1.26.3"
pytest = "^6.2.2"
pandas = "^1.2.3"
pyarrow = "^3.0.0"
numpy = "^1.20.1"
pyodbc = "^4.0.30"
responses = "^0.12.1"
openpyxl = "^3.0.6"
SQLAlchemy = "^1.3.23"
dataclasses-json = "^0.5.2"
当我 运行
poetry add dataclasses
我明白了
SolverProblemError
The current project's Python requirement (>=2.7,<2.8 || >=3.4) is not compatible with some of the required packages Python requirement:
- dataclasses requires Python >=3.6, <3.7, so it will not be satisfied for Python >=2.7,<2.8 || >=3.4,<3.6 || >=3.7
Because no versions of dataclasses match >0.8,<0.9
and dataclasses (0.8) requires Python >=3.6, <3.7, dataclasses is forbidden.
So, because my-project depends on dataclasses (^0.8), version solving failed.
at ~\.poetry\lib\poetry\puzzle\solver.py:241 in _solve
237│ packages = result.packages
238│ except OverrideNeeded as e:
239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240│ except SolveFailure as e:
→ 241│ raise SolverProblemError(e)
242│
243│ results = dict(
244│ depth_first_search(
245│ PackageNode(self._package, packages), aggregate_package_nodes
• Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties
For dataclasses, a possible solution would be to set the `python` property to ">=3.6,<3.7"
https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
https://python-poetry.org/docs/dependency-specification/#using-environment-markers
这里有什么问题?数据类适用于 python 3.9
dataclasses
模块是 python3.7
及更高版本标准库的一部分。如果你也想支持 python3.6
,你只需要安装它(另见 PyPI 上的 the description:“A backport of the dataclasses module for Python 3.6").错误消息也会告诉您这一点,但如果您不是计算机,则以某种方式有点难以理解。
鉴于您的 python 版本似乎是 3.9,您无需执行任何操作 - 您只需使用数据类即可。