【问题标题】:Using poetry on different machines在不同的机器上使用诗歌
【发布时间】:2021-06-22 21:44:03
【问题描述】:

我正在做一个 Python 项目,最近开始使用诗歌。我最初使用 macOS 11.0 进行该项目,但当我接近完成时,我想在 Linux 工作站上对其进行测试。我使用 Github 作为我的存储库,因此,我可以轻松地克隆存储库。然而,这就是简单部分结束的地方。我在 macOS 上的虚拟环境中使用了 pyenv 和 conda,但是当我将 repo 克隆到工作站上时,我设置了一个环境,然后尝试以下命令:

poetry shell
poetry install

poetry install 之后我收到以下错误:

  ParseVersionError

  Unable to parse "at20RC5+54.g5702a232fe.dirty".

  at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/semver/version.py:211 in parse
      207│         except TypeError:
      208│             match = None
      209│
      210│         if match is None:
    → 211│             raise ParseVersionError('Unable to parse "{}".'.format(text))
      212│
      213│         text = text.rstrip(".")
      214│
      215│         major = int(match.group(1))

我尝试poetry lock 得到相同的结果,我什至删除了poetry.lock 并尝试poetry lock 没有成功。

我打算在一切完成后构建并发布它,但因为我最终想添加我的 Mac 没有的功能(例如 CUDA),所以我也想在工作站上编写代码。

任何帮助将不胜感激。

更新 -- 21 年 3 月 27 日

pyproject.toml

[tool.poetry]
name = "qaa"
version = "0.1.0"
description = "Quasi-Anharmonic Analysis"
authors = ["Timothy H. Click <tclick@okstate.edu>"]
license = "BSD-3-Clause"
readme = "README.rst"
homepage = "https://github.com/tclick/qaa"
repository = "https://github.com/tclick/qaa"
documentation = "https://qaa.readthedocs.io"
classifiers = [
    "Programming Language :: Python :: 3.6",
    "Programming Language :: Python :: 3.7",
    "Programming Language :: Python :: 3.8",
    "Programming Language :: Python :: 3.9",
]

[tool.poetry.urls]
Changelog = "https://github.com/tclick/qaa/releases"

[tool.poetry.dependencies]
python = "^3.8"
click = "^7.0"
numpy = "^1.20.1"
scipy = "^1.6.1"
matplotlib = "^3.3.4"
seaborn = "^0.11.1"
scikit-learn = "^0.24.1"
pandas = "^1.2.3"
netCDF4 = "^1.5.6"
mdtraj = "^1.9.5"

[tool.poetry.dev-dependencies]
pytest = "^6.2.2"
pytest-cache = "^1.0"
pytest-click = "^1.0.2"
pytest-console-scripts = "^1.1.0"
pytest-cov = "^2.11.1"
pytest-flake8 = "^1.0.7"
pytest-mock = "^3.5.1"
pytest-pep8 = "^1.0.6"
pytest-randomly = "^3.5.0"
coverage = {extras = ["toml"], version = "^5.3"}
safety = "^1.9.0"
mypy = "^0.812"
typeguard = "^2.9.1"
xdoctest = {extras = ["colors"], version = "^0.15.0"}
sphinx = "^3.3.1"
sphinx-autobuild = "^2020.9.1"
pre-commit = "^2.8.2"
flake8 = "^3.8.4"
black = "^20.8b1"
flake8-bandit = "^2.1.2"
flake8-bugbear = "^21.3.2"
flake8-docstrings = "^1.5.0"
flake8-rst-docstrings = "^0.0.14"
pep8-naming = "^0.11.1"
darglint = "^1.5.5"
reorder-python-imports = "^2.3.6"
pre-commit-hooks = "^3.3.0"
sphinx-rtd-theme = "^0.5.0"
sphinx-click = "^2.5.0"
Pygments = "^2.7.2"
ipython = "^7.21.0"
isort = "^5.7.0"
towncrier = "^19.2.0"
nox = "^2020.12.31"
pytest-coverage = "^0.0"
nox-poetry = "^0.8.4"
numpydoc = "^1.1.0"
codecov = "^2.1.11"
flake8-black = "^0.2.1"
flake8-import-order = "^0.18.1"

[tool.poetry.scripts]
qaa = "qaa.__main__:main"

更新 -- 03/29/21

这是运行poetry lock -vvv时收到的错误

Using virtualenv: /home/tclick/.cache/pypoetry/virtualenvs/qaa-VNW0yB_S-py3.8

  Stack trace:

  10  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/console_application.py:131 in run
       129│             parsed_args = resolved_command.args
       130│
     → 131│             status_code = command.handle(parsed_args, io)
       132│         except KeyboardInterrupt:
       133│             status_code = 1

   9  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py:120 in handle
       118│     def handle(self, args, io):  # type: (Args, IO) -> int
       119│         try:
     → 120│             status_code = self._do_handle(args, io)
       121│         except KeyboardInterrupt:
       122│             if io.is_debug():

   8  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py:163 in _do_handle
       161│         if self._dispatcher and self._dispatcher.has_listeners(PRE_HANDLE):
       162│             event = PreHandleEvent(args, io, self)
     → 163│             self._dispatcher.dispatch(PRE_HANDLE, event)
       164│
       165│             if event.is_handled():

   7  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/event/event_dispatcher.py:22 in dispatch
        20│
        21│         if listeners:
     →  22│             self._do_dispatch(listeners, event_name, event)
        23│
        24│         return event

   6  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/event/event_dispatcher.py:89 in _do_dispatch
        87│                 break
        88│
     →  89│             listener(event, event_name, self)
        90│
        91│     def _sort_listeners(self, event_name):  # type: (str) -> None

   5  ~/.poetry/lib/poetry/console/config/application_config.py:141 in set_installer
       139│
       140│         poetry = command.poetry
     → 141│         installer = Installer(
       142│             event.io,
       143│             command.env,

   4  ~/.poetry/lib/poetry/installation/installer.py:65 in __init__
        63│         self._installer = self._get_installer()
        64│         if installed is None:
     →  65│             installed = self._get_installed()
        66│
        67│         self._installed_repository = installed

   3  ~/.poetry/lib/poetry/installation/installer.py:561 in _get_installed
       559│
       560│     def _get_installed(self):  # type: () -> InstalledRepository
     → 561│         return InstalledRepository.load(self._env)
       562│

   2  ~/.poetry/lib/poetry/repositories/installed_repository.py:118 in load
       116│                 path = Path(str(distribution._path))
       117│                 version = distribution.metadata["version"]
     → 118│                 package = Package(name, version, version)
       119│                 package.description = distribution.metadata.get("summary", "")
       120│

   1  ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/packages/package.py:61 in __init__
        59│
        60│         if not isinstance(version, Version):
     →  61│             self._version = Version.parse(version)
        62│             self._pretty_version = pretty_version or version
        63│         else:

  ParseVersionError

  Unable to parse "at20RC5+54.g5702a232fe.dirty".

  at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/semver/version.py:206 in parse
      202│         except TypeError:
      203│             match = None
      204│
      205│         if match is None:
    → 206│             raise ParseVersionError('Unable to parse "{}".'.format(text))
      207│
      208│         text = text.rstrip(".")
      209│
      210│         major = int(match.group(1))

【问题讨论】:

  • 你能出示你的pyproject.toml吗?
  • 您可能希望显示命令的详细输出:poetry install -vvv。这可能有助于确定哪个依赖项具有这个不寻常的版本字符串。

标签: python-packaging python-poetry


【解决方案1】:

我认为你不应该先运行poetry shell。仅在安装了诗歌项目及其依赖项时使用。

poetry install 应该可以在带有pyproject.toml 的项目目录中正常工作

可能的帮助:

  • 确保在 PATH 中安装了诗歌和诗歌可执行文件的路径 环境变量;
  • 检查是否安装了 python 3.8+(来自您的依赖项)。如果 您使用 pyenv 检查此版本的路径是否可用于 终端。

【讨论】:

    猜你喜欢
    • 2022-08-11
    • 1970-01-01
    • 1970-01-01
    • 2022-11-13
    • 2022-08-12
    • 2022-06-15
    • 2021-11-10
    • 1970-01-01
    • 2020-05-31
    相关资源
    最近更新 更多