Traceback when calling "poetry" command: ModuleNotFoundError: No module named 'cachecontrol'

Bug #1958227 reported by Thomas Bechtold
62
This bug affects 13 people
Affects Status Importance Assigned to Milestone
poetry (Debian)
Fix Released
Unknown
poetry (Ubuntu)
Fix Released
High
Unassigned
Jammy
Fix Released
High
Unassigned
Kinetic
Fix Released
High
Unassigned

Bug Description

I installed poetry via apt (on Jammy amd64) and when I try to call the program, I get:

$ poetry
Traceback (most recent call last):
  File "/usr/bin/poetry", line 5, in <module>
    from poetry.console import main
  File "/usr/lib/python3/dist-packages/poetry/console/__init__.py", line 1, in <module>
    from .application import Application
  File "/usr/lib/python3/dist-packages/poetry/console/application.py", line 7, in <module>
    from .commands.about import AboutCommand
  File "/usr/lib/python3/dist-packages/poetry/console/commands/__init__.py", line 4, in <module>
    from .check import CheckCommand
  File "/usr/lib/python3/dist-packages/poetry/console/commands/check.py", line 2, in <module>
    from poetry.factory import Factory
  File "/usr/lib/python3/dist-packages/poetry/factory.py", line 18, in <module>
    from .repositories.pypi_repository import PyPiRepository
  File "/usr/lib/python3/dist-packages/poetry/repositories/pypi_repository.py", line 11, in <module>
    from cachecontrol import CacheControl
ModuleNotFoundError: No module named 'cachecontrol'

$ dpkg -l|grep python3-poetry
ii python3-poetry 1.1.12+dfsg-1 all Python dependency management and packaging made easy (Python 3)
ii python3-poetry-core 1.0.7-2 all Poetry PEP 517 Build Backend

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: python3-poetry 1.1.12+dfsg-1
ProcVersionSignature: Ubuntu 5.13.0-22.22-generic 5.13.19
Uname: Linux 5.13.0-22-generic x86_64
NonfreeKernelModules: zfs zunicode zavl icp zcommon znvpair
ApportVersion: 2.20.11-0ubuntu75
Architecture: amd64
CasperMD5CheckResult: unknown
CurrentDesktop: ubuntu:GNOME
Date: Tue Jan 18 10:49:59 2022
InstallationDate: Installed on 2020-12-08 (405 days ago)
InstallationMedia: Ubuntu 20.10 "Groovy Gorilla" - Release amd64 (20201022)
PackageArchitecture: all
RebootRequiredPkgs: Error: path contained symlinks.
SourcePackage: poetry
UpgradeStatus: Upgraded to jammy on 2021-11-30 (49 days ago)

### SRU process ###

[Impact]

Problem: the python3-poetry package misses a run-time dependency on python3-cachecontrol
Result: the poetry program "crashes" on startup

Users expect packages from the official repository to work out of the box. This is not the case here as can be seen above unless the user happens to already have the python3-cachecontrol package installed.

The release in lunar was fixed through a later release in Debian and is not affected by this bug as can be verified from the Debian BTS.

[Test]

1) spin up a jammy virtual server or other test environment, no GUI is required.
2) "sudo apt purge python3-cachecontrol;sudo apt install python3-poetry"
3) "poetry" -> failure with current package
4) "sudo apt install python3-cachecontrol"
5) "poetry" -> no more failure

[Regression potential]

The python3-cachecontrol package is required for the poetry binary to start successfully. This change does not introduce any change in code execution paths and should thus be free from introducing any regression.

Revision history for this message
Thomas Bechtold (toabctl) wrote :
Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Thanks for taking your time to report this issue and help making Ubuntu better.

I can confirm I get the same error message when attempting to run poetry on Ubuntu Jammy. After some digging I found a corresponding bug report in Debian (see the attached bug watch), which also explains the root cause. Poetry has an odd dependency on "python3-cachecontrol (>= 0.12.6) | python3 (>> 3.6)", and since python3 is already installed it skips the cachecontrol package. Based on the upstream report, they are looking into how to get the dependencies generated properly.

Until then, you can install "python3-cachecontrol" manually as a workaround. After doing that, poetry now lists information on usage and seems to be working as expected.

Changed in poetry (Ubuntu):
status: New → Confirmed
tags: added: packaging
Changed in poetry (Debian):
status: Unknown → New
Revision history for this message
Akash (mishraakashmyself) wrote :

It requires to upgrade version. Please make sure to install correct version of cachecontrol and try again to install poetry.

Some reference here might help:

https://lifesaver.codes/answer/modulenotfounderror-no-module-named-cleo-3071
https://www.quizcure.com/python/modulenotfounderror-no-module-named-exceptions
https://githubhot.com/repo/python-poetry/poetry/issues/4463

Revision history for this message
Thomas Bechtold (toabctl) wrote :

@Akash,

this is about the debian package (which handles the dependencies).
The bug ist still there. Easy reproducer is:

$ sudo apt install python3-poetry
$ poetry
Traceback (most recent call last):
  File "/usr/bin/poetry", line 5, in <module>
    from poetry.console import main
  File "/usr/lib/python3/dist-packages/poetry/console/__init__.py", line 1, in <module>
    from .application import Application
  File "/usr/lib/python3/dist-packages/poetry/console/application.py", line 7, in <module>
    from .commands.about import AboutCommand
  File "/usr/lib/python3/dist-packages/poetry/console/commands/__init__.py", line 4, in <module>
    from .check import CheckCommand
  File "/usr/lib/python3/dist-packages/poetry/console/commands/check.py", line 2, in <module>
    from poetry.factory import Factory
  File "/usr/lib/python3/dist-packages/poetry/factory.py", line 18, in <module>
    from .repositories.pypi_repository import PyPiRepository
  File "/usr/lib/python3/dist-packages/poetry/repositories/pypi_repository.py", line 11, in <module>
    from cachecontrol import CacheControl
ModuleNotFoundError: No module named 'cachecontrol'

Revision history for this message
Robin Winslow (nottrobin) wrote :

Yes I also got this on a very fresh install of 22.04. I've done very little to customise the system, I've only done `apt install python3-venv python3-poetry`.

This package should include the "cachecontrol" dependency. Presumably a very simple fix.

Revision history for this message
Felixoid (felixoid) wrote (last edit ):

It's a very sad story about Debian and ubuntu package development. A relatively major bug with a one-line fix will celebrate a birthday soon.

Changed in poetry (Debian):
status: New → Fix Released
Revision history for this message
Rolf Leggewie (r0lf) wrote :

This was fixed in Debian in release Version: 1.2.2+dfsg-1. As such, it should not affect lunar.

Keeping the ticket open to work on an SRU to jammy.

Revision history for this message
Rolf Leggewie (r0lf) wrote :
Rolf Leggewie (r0lf)
description: updated
description: updated
Rolf Leggewie (r0lf)
description: updated
Jeremy Bícha (jbicha)
Changed in poetry (Ubuntu Jammy):
importance: Undecided → High
Changed in poetry (Ubuntu):
importance: Undecided → High
Changed in poetry (Ubuntu Jammy):
status: New → Triaged
Revision history for this message
Rolf Leggewie (r0lf) wrote :
Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Sponsored to the jammy and kinetic unapproved queues.

Changed in poetry (Ubuntu Jammy):
status: Triaged → In Progress
Changed in poetry (Ubuntu Kinetic):
status: New → Fix Committed
status: Fix Committed → In Progress
Changed in poetry (Ubuntu):
status: Confirmed → Fix Released
Changed in poetry (Ubuntu Kinetic):
importance: Undecided → High
Revision history for this message
Simon Quigley (tsimonq2) wrote :

Removing the sponsors team, please re-add us if there is anything further we can do to help.

Thanks!

Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

Hello Thomas, or anyone else affected,

Accepted poetry into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/poetry/1.1.12+dfsg-1ubuntu1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in poetry (Ubuntu Jammy):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-jammy
Changed in poetry (Ubuntu Kinetic):
status: In Progress → Fix Committed
tags: added: verification-needed-kinetic
Revision history for this message
Timo Aaltonen (tjaalton) wrote :

Hello Thomas, or anyone else affected,

Accepted poetry into kinetic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/poetry/1.1.14+dfsg-1ubuntu1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-kinetic to verification-done-kinetic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-kinetic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

I reproduced the issue in both jammy and kinetic. python3-poetry 1.1.12+dfsg-1ubuntu1 (jammy-proposed) respective python3-poetry 1.1.14+dfsg-1ubuntu1 (kinetic-proposed) fixes it by installing python3-cachecontrol.

tags: added: verification-done verification-done-jammy verification-done-kinetic
removed: verification-needed verification-needed-jammy verification-needed-kinetic
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package poetry - 1.1.14+dfsg-1ubuntu1

---------------
poetry (1.1.14+dfsg-1ubuntu1) kinetic; urgency=medium

  * add runtime dependency on python3-cachecontrol. LP: #1958227
  * update Maintainer to Ubuntu mailing list

 -- Rolf Leggewie <email address hidden> Wed, 11 Jan 2023 18:09:40 +0100

Changed in poetry (Ubuntu Kinetic):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for poetry has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package poetry - 1.1.12+dfsg-1ubuntu1

---------------
poetry (1.1.12+dfsg-1ubuntu1) jammy-proposed; urgency=medium

  * add runtime dependency on python3-cachecontrol. LP: #1958227
  * update Maintainer to Ubuntu mailing list

 -- Rolf Leggewie <email address hidden> Wed, 11 Jan 2023 10:44:59 +0100

Changed in poetry (Ubuntu Jammy):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.