ModuleNotFoundError: No module named 'exceptiongroup' (with poetry and python 3.10.1+)

See original GitHub issue

Environment

  • cattrs version: 22.1.0
  • Python version: 3.10.5
  • Operating System: Ubuntu 22.04

Description

When using poetry, the dependency spec for cattrs 22.1.0 doesn’t install exceptiongroup for python versions >=3.10.1, <3.11.

It seems that pip interprets the constraint python = "<= 3.10" as roughly equivalent to python = "< 3.11", whereas poetry interprets it (perhaps more correctly?) as python = "<= 3.10.0", so doesn’t behave correctly for patch versions greater than 0. In other words, on python 3.10.1, poetry’s dependency resolver thinks exceptiongroup doesn’t need to be installed.

Looks like this was already fixed in main. No need to rush the next minor release (22.2.0) if it’s not ready, but a patch release for this (22.1.1) would be helpful.

What I Did

Start with python 3.10.1+ installed, and a minimal pyproject.toml:

[tool.poetry]
name = "cattrs-test"
version = "0.1.0"
description = ""
authors = []

[tool.poetry.dependencies]
python = ">=3.10.1,<3.11"
cattrs = "22.1.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Then run from the command line:

pip install poetry  # If not already installed
poetry install
python -c "import cattrs"

Traceback:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/user/.virtualenvs/cattrs-test/lib/python3.10/site-packages/cattrs/__init__.py", line 1, in <module>
    from cattr import converters, disambiguators, dispatch, errors, gen, preconf
  File "/home/user/.virtualenvs/cattrs-test/lib/python3.10/site-packages/cattr/__init__.py", line 1, in <module>
    from .converters import Converter, GenConverter, UnstructureStrategy
  File "/home/user/.virtualenvs/cattrs-test/lib/python3.10/site-packages/cattr/converters.py", line 1, in <module>
    from cattrs.converters import Converter, GenConverter, UnstructureStrategy
  File "/home/user/.virtualenvs/cattrs-test/lib/python3.10/site-packages/cattrs/converters.py", line 12, in <module>
    from cattrs.errors import IterableValidationError, StructureHandlerNotFoundError
  File "/home/user/.virtualenvs/cattrs-test/lib/python3.10/site-packages/cattrs/errors.py", line 3, in <module>
    from cattrs._compat import ExceptionGroup
  File "/home/user/.virtualenvs/cattrs-test/lib/python3.10/site-packages/cattrs/_compat.py", line 38, in <module>
    from exceptiongroup import ExceptionGroup
ModuleNotFoundError: No module named 'exceptiongroup'

Attached is an example poetry.lock showing that exceptiongroup wasn’t picked up by the dependency resolver.

Workaround

This can be worked around by adding an explicit dependency on exceptiongroup, so I wouldn’t consider this a super serious bug, but it would be helpful to have a PyPI release that fixes this for other users of cattrs + poetry + python 3.10.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:5
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JWCookcommented, Oct 8, 2022

This is now fixed with the 22.2 release. Thanks!

0reactions
JWCookcommented, Jun 29, 2022

Sure! And thank you for the lovely library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

poetry add | ModuleNotFoundError: No module named 'copier'
Copier Git Issue claimed it's an Poetry issue. Describe the problem pip install copier but ModuleNotFoundError: No module named 'copier'.
Read more >
No module named` after poetry install for package - Stack ...
I have a containerfile to download poetry and install packages but when I go into my container and run python script. I keep...
Read more >
EnvCommandError - cannot get django tutorial to deploy
I created an environment variable to get render to use python 3.8.2 ... Oct 16 08:24:48 PM ModuleNotFoundError: No module named 'setuptools'
Read more >
Introduction | Documentation | Poetry - Python dependency ...
Poetry is a tool for dependency management and packaging in Python. ... This ensures that dependencies will not be accidentally upgraded or uninstalled, ......
Read more >
poetry - PyPI
Poetry helps you declare, manage and install dependencies of Python projects, ensuring you have the right stack everywhere. Poetry Install. Poetry replaces ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found