question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ModuleNotFoundError: No module named 'poetry.core.packages.dependency_group'

See original GitHub issue
  • 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: Gentoo GNU/Linux (rolling)
  • Poetry version: 1.2.1 (Core 1.2.0)
  • Link of a Gist with the contents of your pyproject.toml file: not applicable

Issue

After a fresh install pip install --user poetry, I wanted to start with poetry --help. I get the following error:

$ poetry --help -vvv
Traceback (most recent call last):
  File "/home/seb/.local/lib/python3.10/site-packages/cleo/application.py", line 329, in run
    exit_code = self._run(io)
  File "/home/seb/.local/lib/python3.10/site-packages/poetry/console/application.py", line 183, in _run
    self._load_plugins(io)
  File "/home/seb/.local/lib/python3.10/site-packages/poetry/console/application.py", line 349, in _load_plugins
    manager.load_plugins()
  File "/home/seb/.local/lib/python3.10/site-packages/poetry/plugins/plugin_manager.py", line 38, in load_plugins
    self._load_plugin_entry_point(ep)
  File "/home/seb/.local/lib/python3.10/site-packages/poetry/plugins/plugin_manager.py", line 76, in _load_plugin_entry_point
    plugin = ep.load()  # type: ignore[no-untyped-call]
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/seb/.local/lib/python3.10/site-packages/poetry_plugin_export/plugins.py", line 7, in <module>
    from poetry_plugin_export.command import ExportCommand
  File "/home/seb/.local/lib/python3.10/site-packages/poetry_plugin_export/command.py", line 4, in <module>
    from poetry.console.commands.group_command import GroupCommand
  File "/home/seb/.local/lib/python3.10/site-packages/poetry/console/commands/group_command.py", line 6, in <module>
    from poetry.core.packages.dependency_group import MAIN_GROUP
ModuleNotFoundError: No module named 'poetry.core.packages.dependency_group'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/seb/.local/bin/poetry", line 8, in <module>
    sys.exit(main())
  File "/home/seb/.local/lib/python3.10/site-packages/poetry/console/application.py", line 388, in main
    exit_code: int = Application().run()
  File "/home/seb/.local/lib/python3.10/site-packages/cleo/application.py", line 334, in run
    self.render_error(e, io)
  File "/home/seb/.local/lib/python3.10/site-packages/poetry/console/application.py", line 175, in render_error
    self.set_solution_provider_repository(self._get_solution_provider_repository())
  File "/home/seb/.local/lib/python3.10/site-packages/poetry/console/application.py", line 377, in _get_solution_provider_repository
    from poetry.mixology.solutions.providers.python_requirement_solution_provider import (  # noqa: E501
  File "/home/seb/.local/lib/python3.10/site-packages/poetry/mixology/__init__.py", line 5, in <module>
    from poetry.mixology.version_solver import VersionSolver
  File "/home/seb/.local/lib/python3.10/site-packages/poetry/mixology/version_solver.py", line 11, in <module>
    from poetry.mixology.failure import SolveFailure
  File "/home/seb/.local/lib/python3.10/site-packages/poetry/mixology/failure.py", line 6, in <module>
    from poetry.core.semver.helpers import parse_constraint
ModuleNotFoundError: No module named 'poetry.core.semver.helpers'

I actually installed poetry-core via my operating system’s package manager beforehands, which installed poetry-core 1.0.8 in the system, but this should not be a problem, since it was installed into /usr/lib/python3.10/site-packages, which comes after /home/seb/.local/lib/python3.10/site-packages on sys.path. (still, /usr/lib/python3.10 comes before it, if that is of any relevance). The pip install --user poetry did install poetry-core 1.2.0 in my .local folder.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
SebAlbertcommented, Sep 18, 2022

So I’ve essentially found that poetry-core used to be an explicit package in 1.0.8 and has become a namespace package as of 1.1.0. (see https://github.com/python-poetry/poetry-core/commit/fa93845ed48f8ba392da3628fd5718a84ebae5d6 ) Bottom line: One must be aware that Python “namespace packages” can lead to version conflicts that are not fully mitigated by just the order of the import path. A clear explanation (easier to read than official Python docs) is on this StackOverflow answer: https://stackoverflow.com/questions/21819649/namespace-vs-regular-package

If either one of them gain an __init__.py that becomes the package - and you no longer get the unification as the other directory is ignored.

0reactions
neersightedcommented, Sep 18, 2022

Keep in mind that user installs are not suggested for exactly this reason – use of a virtual environment will prevent this kind of issue. Thanks for digging in!

Read more comments on GitHub >

github_iconTop Results From Across the Web

No module named poetry.core on Py3.9.0b1 #2449 - GitHub
I created a virtual environment. Then I needed to install Apache Airflow. But the program stopped and reported an error (ModuleNotFoundError: No ......
Read more >
No module named` after poetry install for package - Stack ...
poetry install installs the package into an venv. You have to activate it first, e.g. with poetry shell . Have a look into...
Read more >
ModuleNotFoundError: No module named 'poetry-core'
Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'poetry-core' How to remove the Module.
Read more >
poetry-core - PyPI
A PEP 517 build backend implementation developed for Poetry. This project is intended to be a light weight, fully compliant, self-contained package allowing...
Read more >
python-poetry-core-git - AUR (en) - Arch Linux
tests/conftest.py:9: in <module> import virtualenv E ModuleNotFoundError: No module named 'virtualenv' ==> ERROR: A failure occurred in check(). Aborting...
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