poetry: ModuleNotFoundError: No module named 'cleo'

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: windows7
  • Poetry version: 1.1.4
  • Python version: 3.7.8

Issue

I cannot run even poetry --version now.

Traceback (most recent call last): File “C:\Users\Administrator.poetry\bin\poetry”, line 12, in <module> from poetry.console import main File “C:\Users\Administrator.poetry\lib\poetry\console_init_.py”, line 1, in <module> from .application import Application File “C:\Users\Administrator.poetry\lib\poetry\console\application.py”, line 3, in <module> from cleo import Application as BaseApplication ModuleNotFoundError: No module named ‘cleo’

#3071 doesn’t solve my problem

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 33 (11 by maintainers)

Commits related to this issue

Most upvoted comments

I’m still hitting this issue and none of the workarounds solve it.

@tedivm Did you manage to resolve the issue? I was having trouble with the same error as well, but finally I realized that my bash was using an old install of Poetry via /home/<username>/.poetry/bin/poetry instead of the new install method’s /home/<username>/.local/bin/poetry. I managed to fix my problems by manually deleting /home/<username>/.poetry, running curl -sSL https://install.python-poetry.org | python3 - and then refreshing the current shell!

On my Mac mini M1 using the get-poetry.py script causes the same message.

EDIT: nvm it just does not work on latest 3.10 release

I’ve had some success in just making a new copy of the ~/.poetry/lib/poetry/_vendor/py3.9 and renaming it to ~/.poetry/lib/poetry/_vendor/py3.10. Then I was able to get things working with a 3.10 installation (should work on windows as well). It’s not great, but might be an acceptable hack until poetry updates to be compatible with 3.10.

@tedivm Did you manage to resolve the issue? I was having trouble with the same error as well, but finally I realized that my bash was using an old install of Poetry via /home/<username>/.poetry/bin/poetry instead of the new install method’s /home/<username>/.local/bin/poetry. I managed to fix my problems by manually deleting /home/<username>/.poetry, running curl -sSL https://install.python-poetry.org | python3 - and then refreshing the current shell!

Nice approach! I solved my problem with this too. I should change .zshrc to export new path!

@Kurt-von-Laven glad it is resolved. Just an FYI, the install script in the poetry repo will eventually be removed and served via install.python-poetry.org. The source for it is available at https://github.com/python-poetry/install.python-poetry.org

Oops, I confused this issue for another issue I’m having in another environment that does use pipx where I keep having to delete the artifacts folder. You are correct that I’m only having this issue where get-poetry is being used.

Apologies for the noise.

@riconnon @Kurt-von-Laven @TaCheJW I’d suggest you remove any existing Poetry installation and then install Poetry again either via pipx or via the installer (as follows).

curl -sSL https://install.python-poetry.org/ | python3 -

Make sure you add the relevant bin directory to your path.

Closing this for now as get-poetry.py is deprecated and the “platform” artifacts are problematic in general.

Looks like the issue is the followin line.

#!/usr/bin/env python3

This means the script will attempt to use the whatever the current active python3 setup us. So, if this is not the same as the one in which you installed poetry into, the required dependencies might not be available. If installed via install-poetry.py you should get something like this.

#!/home/derek/.local/share/pypoetry/venv/bin/python
podman run --rm -i --entrypoint bash python:3.8 <<EOF
set -xe
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -
cat /root/.local/bin/poetry
EOF
$ podman run --rm -i --entrypoint bash python:3.8 <<EOF
set -xe
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -
cat /root/.local/bin/poetry
EOF
+ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py
+ python -
Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

/root/.local/bin

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing Poetry (1.1.11)
Installing Poetry (1.1.11): Creating environment
Installing Poetry (1.1.11): Installing Poetry
Installing Poetry (1.1.11): Creating script
Installing Poetry (1.1.11): Done

Poetry (1.1.11) is installed now. Great!

To get started you need Poetry's bin directory (/root/.local/bin) in your `PATH`
environment variable.

Add `export PATH="/root/.local/bin:$PATH"` to your shell configuration file.

Alternatively, you can call Poetry explicitly with `/root/.local/bin/poetry`.

You can test that everything is set up by executing:

`poetry --version`

+ cat /root/.local/bin/poetry
#!/root/.local/share/pypoetry/venv/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from poetry.console import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

Looks like you might have installed poetry previously usin the get-poetry.py script. I would recommend you uninstall first using that or manually removing ~/.poetry and the entry point script.

Then use the following command to install a brand new instance.

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -

Note you can modify python to python3 or to a specific executable as you desire.

I had the same problem after updating to python 3.9 but the issue went away after “pip install --user poetry”. Note that I use python through pyenv.