诗歌安装 | SolverProblemError Because my_project depends on string (*) which doesn't match any versions, 版本解析失败
poetry install | SolverProblemError Because my_project depends on string (*) which doesn't match any versions, version solving failed
我还没有用诗歌来 运行 项目,所以请原谅缺乏理解。
我成功安装了诗歌python图书馆管理器,使用:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
下一步 poetry install
最初返回此错误:
me@LAPTOP-G1DAPU88:~/.ssh/workers-python/workers$ poetry install
RuntimeError
Poetry could not find a pyproject.toml file in /home/me/.ssh/workers-python/workers or its parents
at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/factory.py:369 in locate
365│ if poetry_file.exists():
366│ return poetry_file
367│
368│ else:
→ 369│ raise RuntimeError(
370│ "Poetry could not find a pyproject.toml file in {} or its parents".format(
371│ cwd
372│ )
373│ )
我很快意识到我需要自己制作的 pyproject.toml
文件。 运行 poetry install
再次产生:
$ poetry install
TOMLError
Invalid TOML file /home/me/.ssh/workers-python/workers/pyproject.toml: Key "json " already exists.
at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/toml/file.py:34 in read
30│ def read(self): # type: () -> "TOMLDocument"
31│ try:
32│ return super(TOMLFile, self).read()
33│ except (ValueError, TOMLKitError) as e:
→ 34│ raise TOMLError("Invalid TOML file {}: {}".format(self.path.as_posix(), e))
35│
36│ def __getattr__(self, item): # type: (str) -> Any
37│ return getattr(self.__path, item)
38│
以上错误表示存在重复条目。
运行 poetry install
再次使用现在更新的 cwd
中的 pyproject.toml
文件抛出此错误(在 post 的标题中):
$ poetry install
Creating virtualenv my_project-1_EUeV5I-py3.8 in /home/me/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies... (28.4s)
SolverProblemError
Because my_project depends on string (*) which doesn't match any versions, 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
但是,暂时删除所有实例 = "*"
给了我 line 12
上的 \n
错误...似乎不存在:
$ poetry install
TOMLError
Invalid TOML file /home/me/.ssh/workers-python/workers/pyproject.toml: Unexpected character: '\n' at line 12 col 5
at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/toml/file.py:34 in read
30│ def read(self): # type: () -> "TOMLDocument"
31│ try:
32│ return super(TOMLFile, self).read()
33│ except (ValueError, TOMLKitError) as e:
→ 34│ raise TOMLError("Invalid TOML file {}: {}".format(self.path.as_posix(), e))
35│
36│ def __getattr__(self, item): # type: (str) -> Any
37│ return getattr(self.__path, item)
38│
me@LAPTOP-G1DAPU88:~/.ssh/workers-python/workers$ cat pyproject.toml
[tool.poetry]
name = "my_project"
version = "0.1.0"
description = "Top-level package for my_project."
authors = [""]
packages = [
{ include = "my_project"},
]
[tool.poetry.dependencies]
python = "^3.8"
click # Suspect line
我已经恢复了这个。
当前 pyproject.toml
:
[tool.poetry]
name = "data_simulator"
version = "0.1.0"
description = "Top-level package for data_simulator."
authors = ["iotahoe <iotahoe@iotahoe.com>"] # daniel.bell@hitachivantara.com / daniel@iotahoe.com
packages = [
{ include = "data_simulator"},
]
[tool.poetry.dependencies]
python = "^3.8"
click = "*"
#logging = "*"
#os = "*"
#pathlib = "*"
#time = "*"
numpy = "*"
pandas = "*"
#json = "*"
#random = "*"
faker = "*"
transformers = "4.4.2"
#re = "*"
#itertools = "*"
#datetime = "*"
#requests = "*"
#copy = "*"
#collections = "*"
#collections.abc = "*"
#multiprocessing = "*"
#multiprocessing.dummy = "*"
nltk = "*"
#nltk.corpus = "*"
#string = "*"
[tool.poetry.dev-dependencies]
isort = "5.6.4"
black = "^20.8b1"
invoke = "^1.4.1"
coveralls = "^2.2.0"
pytest = "^3.0"
flake8 = "^3.8.3"
mypy = "^0.782"
[[tool.poetry.source]]
name = "azure"
url = "https://pkgs.dev.azure.com/iotahoe/Halo/_packaging/private-sources/pypi/simple/"
secondary = true
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
注意:'name'、'authors'、'include'、'url' 已被删减。
作为一般建议,我建议使用 poetry 的命令行而不是 creating/manipulating pyproject.toml
。
从 poetry init
或 poetry init -n
开始并使用 poetry add
添加您的依赖项。
您当前 pyproject.toml
的问题是,您将内置包声明为依赖项,例如 os、pathlib、string 等。这就是为什么你会收到消息 Because my_project depends on string (*) which doesn't match any versions, version solving failed.
,这意味着 poetry 在 repos 中找不到任何匹配的包信息。
tl;dr: 在 运行ning poetry lock
.
之前刷新 *.egg-info
目录
这个答案与当前问题没有严格的关系,但在其他情况下也会出现类似的错误信息,所以我认为在这里分享它是有价值的。
如果您锁定的项目中 sub-dependencies 可直接在文件系统上使用,某些 *.egg-info
目录可能会干扰锁定过程,导致在尝试 运行 时出现问题poetry install
在那些 *.egg-info
文件丢失的上下文中。要避免此问题: 在锁定之前刷新 *.egg-info
目录。然后您应该有一个包含更多内容的更新 poetry.lock
文件。
我还没有用诗歌来 运行 项目,所以请原谅缺乏理解。
我成功安装了诗歌python图书馆管理器,使用:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
下一步 poetry install
最初返回此错误:
me@LAPTOP-G1DAPU88:~/.ssh/workers-python/workers$ poetry install
RuntimeError
Poetry could not find a pyproject.toml file in /home/me/.ssh/workers-python/workers or its parents
at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/factory.py:369 in locate
365│ if poetry_file.exists():
366│ return poetry_file
367│
368│ else:
→ 369│ raise RuntimeError(
370│ "Poetry could not find a pyproject.toml file in {} or its parents".format(
371│ cwd
372│ )
373│ )
我很快意识到我需要自己制作的 pyproject.toml
文件。 运行 poetry install
再次产生:
$ poetry install
TOMLError
Invalid TOML file /home/me/.ssh/workers-python/workers/pyproject.toml: Key "json " already exists.
at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/toml/file.py:34 in read
30│ def read(self): # type: () -> "TOMLDocument"
31│ try:
32│ return super(TOMLFile, self).read()
33│ except (ValueError, TOMLKitError) as e:
→ 34│ raise TOMLError("Invalid TOML file {}: {}".format(self.path.as_posix(), e))
35│
36│ def __getattr__(self, item): # type: (str) -> Any
37│ return getattr(self.__path, item)
38│
以上错误表示存在重复条目。
运行 poetry install
再次使用现在更新的 cwd
中的 pyproject.toml
文件抛出此错误(在 post 的标题中):
$ poetry install
Creating virtualenv my_project-1_EUeV5I-py3.8 in /home/me/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies... (28.4s)
SolverProblemError
Because my_project depends on string (*) which doesn't match any versions, 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
但是,暂时删除所有实例 = "*"
给了我 line 12
上的 \n
错误...似乎不存在:
$ poetry install
TOMLError
Invalid TOML file /home/me/.ssh/workers-python/workers/pyproject.toml: Unexpected character: '\n' at line 12 col 5
at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/toml/file.py:34 in read
30│ def read(self): # type: () -> "TOMLDocument"
31│ try:
32│ return super(TOMLFile, self).read()
33│ except (ValueError, TOMLKitError) as e:
→ 34│ raise TOMLError("Invalid TOML file {}: {}".format(self.path.as_posix(), e))
35│
36│ def __getattr__(self, item): # type: (str) -> Any
37│ return getattr(self.__path, item)
38│
me@LAPTOP-G1DAPU88:~/.ssh/workers-python/workers$ cat pyproject.toml
[tool.poetry]
name = "my_project"
version = "0.1.0"
description = "Top-level package for my_project."
authors = [""]
packages = [
{ include = "my_project"},
]
[tool.poetry.dependencies]
python = "^3.8"
click # Suspect line
我已经恢复了这个。
当前 pyproject.toml
:
[tool.poetry]
name = "data_simulator"
version = "0.1.0"
description = "Top-level package for data_simulator."
authors = ["iotahoe <iotahoe@iotahoe.com>"] # daniel.bell@hitachivantara.com / daniel@iotahoe.com
packages = [
{ include = "data_simulator"},
]
[tool.poetry.dependencies]
python = "^3.8"
click = "*"
#logging = "*"
#os = "*"
#pathlib = "*"
#time = "*"
numpy = "*"
pandas = "*"
#json = "*"
#random = "*"
faker = "*"
transformers = "4.4.2"
#re = "*"
#itertools = "*"
#datetime = "*"
#requests = "*"
#copy = "*"
#collections = "*"
#collections.abc = "*"
#multiprocessing = "*"
#multiprocessing.dummy = "*"
nltk = "*"
#nltk.corpus = "*"
#string = "*"
[tool.poetry.dev-dependencies]
isort = "5.6.4"
black = "^20.8b1"
invoke = "^1.4.1"
coveralls = "^2.2.0"
pytest = "^3.0"
flake8 = "^3.8.3"
mypy = "^0.782"
[[tool.poetry.source]]
name = "azure"
url = "https://pkgs.dev.azure.com/iotahoe/Halo/_packaging/private-sources/pypi/simple/"
secondary = true
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
注意:'name'、'authors'、'include'、'url' 已被删减。
作为一般建议,我建议使用 poetry 的命令行而不是 creating/manipulating pyproject.toml
。
从 poetry init
或 poetry init -n
开始并使用 poetry add
添加您的依赖项。
您当前 pyproject.toml
的问题是,您将内置包声明为依赖项,例如 os、pathlib、string 等。这就是为什么你会收到消息 Because my_project depends on string (*) which doesn't match any versions, version solving failed.
,这意味着 poetry 在 repos 中找不到任何匹配的包信息。
tl;dr: 在 运行ning poetry lock
.
*.egg-info
目录
这个答案与当前问题没有严格的关系,但在其他情况下也会出现类似的错误信息,所以我认为在这里分享它是有价值的。
如果您锁定的项目中 sub-dependencies 可直接在文件系统上使用,某些 *.egg-info
目录可能会干扰锁定过程,导致在尝试 运行 时出现问题poetry install
在那些 *.egg-info
文件丢失的上下文中。要避免此问题: 在锁定之前刷新 *.egg-info
目录。然后您应该有一个包含更多内容的更新 poetry.lock
文件。