Search code examples
pythonvirtualenvpython-poetry

Creating new poetry environment broken (ImportError: cannot import name 'main' from 'poetry.console')


I want to create a new poetry environment for my poetry project because I deleted the one I had: enter image description here

But I have the following error: enter image description here

Here is the command output:

Traceback (most recent call last):
  File "C:\Users\lhott\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\lhott\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\lhott\AppData\Roaming\Python\Scripts\poetry.exe\__main__.py", line 4, in <module>
ImportError: cannot import name 'main' from 'poetry.console' (C:\Users\lhott\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\console\__init__.py)

Solution

  • Uninstalling poetry and re-installing it with:

    (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
    

    solved the problem.