我还没有使用诗歌来运行项目,所以请原谅缺乏理解。
\n我成功安装了诗歌Python库管理器,使用:
\ncurl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3\nRun Code Online (Sandbox Code Playgroud)\n下一步poetry install最初返回此错误:
me@LAPTOP-G1DAPU88:~/.ssh/workers-python/workers$ poetry install\n\n RuntimeError\n\n Poetry could not find a pyproject.toml file in /home/me/.ssh/workers-python/workers or its parents\n\n at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/factory.py:369 in locate\n 365\xe2\x94\x82 if poetry_file.exists():\n 366\xe2\x94\x82 return poetry_file\n 367\xe2\x94\x82\n 368\xe2\x94\x82 else:\n \xe2\x86\x92 369\xe2\x94\x82 raise RuntimeError(\n 370\xe2\x94\x82 "Poetry could not find a pyproject.toml file in {} or its parents".format(\n 371\xe2\x94\x82 cwd\n 372\xe2\x94\x82 )\n 373\xe2\x94\x82 )\nRun Code Online (Sandbox Code Playgroud)\n我很快意识到我需要自己制作的pyproject.toml文件。poetry install再次运行得到:
$ poetry install\n\n TOMLError\n\n Invalid TOML file /home/me/.ssh/workers-python/workers/pyproject.toml: Key "json " already exists.\n\n at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/toml/file.py:34 in read\n 30\xe2\x94\x82 def read(self): # type: () -> "TOMLDocument"\n 31\xe2\x94\x82 try:\n 32\xe2\x94\x82 return super(TOMLFile, self).read()\n 33\xe2\x94\x82 except (ValueError, TOMLKitError) as e:\n \xe2\x86\x92 34\xe2\x94\x82 raise TOMLError("Invalid TOML file {}: {}".format(self.path.as_posix(), e))\n 35\xe2\x94\x82\n 36\xe2\x94\x82 def __getattr__(self, item): # type: (str) -> Any\n 37\xe2\x94\x82 return getattr(self.__path, item)\n 38\xe2\x94\x82\nRun Code Online (Sandbox Code Playgroud)\n上述错误表明存在重复条目。
\npoetry install使用现在更新的pyproject.toml文件再次运行会cwd引发此错误(在帖子的标题中):
$ poetry install\nCreating virtualenv my_project-1_EUeV5I-py3.8 in /home/me/.cache/pypoetry/virtualenvs\nUpdating dependencies\nResolving dependencies... (28.4s)\n\n SolverProblemError\n\n Because my_project depends on string (*) which doesn't match any versions, version solving failed.\n\n at ~/.poetry/lib/poetry/puzzle/solver.py:241 in _solve\n 237\xe2\x94\x82 packages = result.packages\n 238\xe2\x94\x82 except OverrideNeeded as e:\n 239\xe2\x94\x82 return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)\n 240\xe2\x94\x82 except SolveFailure as e:\n \xe2\x86\x92 241\xe2\x94\x82 raise SolverProblemError(e)\n 242\xe2\x94\x82\n 243\xe2\x94\x82 results = dict(\n 244\xe2\x94\x82 depth_first_search(\n 245\xe2\x94\x82 PackageNode(self._package, packages), aggregate_package_nodes\nRun Code Online (Sandbox Code Playgroud)\n然而,暂时删除所有实例给了我这个on ...= "*"的错误,但它似乎不存在:\\nline 12
$ poetry install\n\n TOMLError\n\n Invalid TOML file /home/me/.ssh/workers-python/workers/pyproject.toml: Unexpected character: '\\n' at line 12 col 5\n\n at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/toml/file.py:34 in read\n 30\xe2\x94\x82 def read(self): # type: () -> "TOMLDocument"\n 31\xe2\x94\x82 try:\n 32\xe2\x94\x82 return super(TOMLFile, self).read()\n 33\xe2\x94\x82 except (ValueError, TOMLKitError) as e:\n \xe2\x86\x92 34\xe2\x94\x82 raise TOMLError("Invalid TOML file {}: {}".format(self.path.as_posix(), e))\n 35\xe2\x94\x82\n 36\xe2\x94\x82 def __getattr__(self, item): # type: (str) -> Any\n 37\xe2\x94\x82 return getattr(self.__path, item)\n 38\xe2\x94\x82\nme@LAPTOP-G1DAPU88:~/.ssh/workers-python/workers$ cat pyproject.toml\n[tool.poetry]\nname = "my_project"\nversion = "0.1.0"\ndescription = "Top-level package for my_project."\nauthors = [""]\npackages = [\n { include = "my_project"},\n]\n\n[tool.poetry.dependencies]\npython = "^3.8"\nclick # Suspect line\nRun Code Online (Sandbox Code Playgroud)\n我已经恢复了这个。
\n当前的pyproject.toml:
[tool.poetry]\nname = "data_simulator"\nversion = "0.1.0"\ndescription = "Top-level package for data_simulator."\nauthors = ["iotahoe <iotahoe@iotahoe.com>"] # daniel.bell@hitachivantara.com / daniel@iotahoe.com\npackages = [\n { include = "data_simulator"},\n]\n\n[tool.poetry.dependencies]\npython = "^3.8"\nclick = "*"\n#logging = "*"\n#os = "*"\n#pathlib = "*"\n#time = "*"\nnumpy = "*"\npandas = "*"\n#json = "*"\n#random = "*"\nfaker = "*"\ntransformers = "4.4.2"\n#re = "*"\n#itertools = "*"\n#datetime = "*"\n#requests = "*"\n#copy = "*"\n#collections = "*"\n#collections.abc = "*"\n#multiprocessing = "*"\n#multiprocessing.dummy = "*"\nnltk = "*"\n#nltk.corpus = "*"\n#string = "*"\n\n[tool.poetry.dev-dependencies]\nisort = "5.6.4"\nblack = "^20.8b1"\ninvoke = "^1.4.1"\ncoveralls = "^2.2.0"\npytest = "^3.0"\nflake8 = "^3.8.3"\nmypy = "^0.782"\n\n[[tool.poetry.source]]\nname = "azure"\nurl = "https://pkgs.dev.azure.com/iotahoe/Halo/_packaging/private-sources/pypi/simple/"\nsecondary = true\n\n[build-system]\nrequires = ["poetry>=0.12"]\nbuild-backend = "poetry.masonry.api"\nRun Code Online (Sandbox Code Playgroud)\n注意:“名称”、“作者”、“包含”、“网址”已被审查。
\nfin*_*mer 26
作为一般建议,我建议使用诗歌的命令行而不是创建/操作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.,这意味着诗歌在存储库中找不到任何匹配的包信息。
| 归档时间: |
|
| 查看次数: |
53115 次 |
| 最近记录: |