python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.76k stars 2.27k forks source link

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

Closed rominf closed 6 years ago

rominf commented 6 years ago

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 commented 6 years ago

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://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
rominf commented 6 years ago

@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 commented 5 years ago

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://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | POETRY_PREVIEW=1 python

Or, in PowerShell, you can run this:

Invoke-WebRequest -UseBasicParsing https://raw.githubusercontent.com/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 commented 5 years ago

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 commented 5 years ago

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

lucastamoios commented 5 years ago

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 commented 5 years ago

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

crgarcia12 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

Oops, of course without =.

Fixed it :laughing:

kigawas commented 4 years ago

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://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | POETRY_PREVIEW=1 python

Or, in PowerShell, you can run this:

Invoke-WebRequest -UseBasicParsing https://raw.githubusercontent.com/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 commented 4 years ago

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 commented 3 years ago

install poetry with pipx fixed pipx install poetry

tomjohnburton commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

MostHated commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

Thank you for your response. Grateful for it.

On Wed, Dec 15, 2021, 6:22 AM Kelvin Ng @.***> wrote:

@PRINCEOYEBOLA https://github.com/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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/python-poetry/poetry/issues/553#issuecomment-994303497, or unsubscribe https://github.com/notifications/unsubscribe-auth/APVZ4PG52KC4AKDIHKQVWWDURAQXXANCNFSM4F66KXGA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

ben-hampson commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

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

ephes commented 2 years ago

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 commented 2 years ago

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

rajee-a commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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://raw.githubusercontent.com/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 commented 2 years ago

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://raw.githubusercontent.com/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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

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 https://github.com/python-poetry/poetry/issues/553#issuecomment-1138702188:

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 commented 2 years ago

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

github-actions[bot] commented 8 months ago

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.