Andrii
Andrii

Reputation: 324

ModuleNotFoundError: No module named 'poetry.console'

Had install poetry lib, when I add to pyproject.toml next setting:

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
style = "pep440"

I get the error:

Traceback (most recent call last):
  File "/home/a-kostenko/.poetry/bin/poetry", line 17, in <module>
    from poetry.console import main
  File "/home/a-kostenko/.local/lib/python3.8/site-packages/poetry_dynamic_versioning/__init__.py", line 409, in alt_import
    module = _state.original_import_func(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'poetry.console'

help please, what is wrong?

Upvotes: 13

Views: 29609

Answers (3)

EdwardFunnyHands
EdwardFunnyHands

Reputation: 153

Sometimes it might not recognize the poetry library even though its present in the venv, a simple solution that worked for me was

pip install poetry

It will update any existing faulty installation of poetry with the latest stable version.

Upvotes: 2

Praveen Kulkarni
Praveen Kulkarni

Reputation: 3221

Try to do which\where poetry. Maybe you have multiple poetry installations. Note that there are two versions now get-poetry.py and install-poetry.py So make sure that you uninstall both and then do a fresh install.

First uninstall everything.

curl -sSL https://install.python-poetry.org > install-poetry.py
python install-poetry.py --uninstall
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py > get-poetry.py
python get-poetry.py --uninstall

Then install again with new install-poetry.py script

curl -sSL https://install.python-poetry.org > install-poetry.py
python install-poetry.py

Then make sure if the path is in environment:

$HOME/.local/bin for Unix
%APPDATA%\Python\Scripts on Windows

Finally test

poetry --version

Upvotes: 19

HappyBob
HappyBob

Reputation: 146

Here is the PowerShell way.

Uninstall

$ul = ("https://install.python-poetry.org",
       "https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py",
       "https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py")

$ul |% { (Invoke-WebRequest -Uri $_ -UseBasicParsing).Content | py - --uninstall }

Reinstall

$ul |% { (Invoke-WebRequest -Uri $_ -UseBasicParsing).Content | py -}

Upvotes: 8

Related Questions