IT技術で仕事を減らしたい!

ITエンジニアのメモ+α

Python Poetry AssertionErrorエラー解消

どうも、nippa です。

Poetry のパッケージ管理で、AssertionError が起きたので解決策をまとめておきます。

環境

  • macOS 11.6
  • poetry 1.1.14

AssertionError の原因

今回起きたのは、pyproject.tomlnameがパッケージ名と同じだったため、AssertionErrorが起きました。

name = "selenium"のときに、selenium をインストールしようとすると起きました。

[tool.poetry]
name = "selenium" <--ここ
version = "0.1.0"
description = ""
authors = ["authors <0000000+authors@users.noreply.github.com>"]

[tool.poetry.dependencies]
python = "^3.9"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

以下のように変更して、再度 selenium をインストールするとインストール可能になりました。

[tool.poetry]
name = "selenium-test" <--変更後
version = "0.1.0"
description = ""
authors = ["authors <0000000+authors@users.noreply.github.com>"]

[tool.poetry.dependencies]
python = "^3.9"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

感想

Poetry のAssertionErrorで悩まれている方の役に立てればと思い、記事に残しておきます。

ではでは、また次回。