ModuleNotFoundError: No module named 'poetry.console'

Viewed 7367

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?

3 Answers

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://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py > 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://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py > 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

Something is wrong with the way Poetry is installed on your machine.

Uninstall it by running these commands in your terminal:

curl https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py > get-poetry

python get-poetry --uninstall

Then reinstall it, preferably with a tool such as pipx

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 -}
Related