Skip to content

import pkg_resources fails in some environments (e.g. did in GitHub Actions) #75

@niccokunzmann

Description

@niccokunzmann

Describe the bug

I could not import pkg_resources

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/nicco/django-oscar-announcements/.venv/lib/python3.11/site-packages/_pytest/main.py", line 314, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "/home/nicco/django-oscar-announcements/.venv/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1165, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "/home/nicco/django-oscar-announcements/.venv/lib/python3.11/site-packages/pluggy/_hooks.py", line 534, in call_historic
INTERNALERROR>     res = self._hookexec(self.name, self._hookimpls.copy(), kwargs, False)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/nicco/django-oscar-announcements/.venv/lib/python3.11/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/nicco/django-oscar-announcements/.venv/lib/python3.11/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR>     raise exception
INTERNALERROR>   File "/home/nicco/django-oscar-announcements/.venv/lib/python3.11/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/nicco/django-oscar-announcements/tests/conftest.py", line 54, in pytest_configure
INTERNALERROR>     django.setup()
INTERNALERROR>   File "/home/nicco/django-oscar-announcements/.venv/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
INTERNALERROR>     apps.populate(settings.INSTALLED_APPS)
INTERNALERROR>   File "/home/nicco/django-oscar-announcements/.venv/lib/python3.11/site-packages/django/apps/registry.py", line 91, in populate
INTERNALERROR>     app_config = AppConfig.create(entry)
INTERNALERROR>                  ^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/nicco/django-oscar-announcements/.venv/lib/python3.11/site-packages/django/apps/config.py", line 193, in create
INTERNALERROR>     import_module(entry)
INTERNALERROR>   File "/home/nicco/.pyenv/versions/3.11.6/lib/python3.11/importlib/__init__.py", line 126, in import_module
INTERNALERROR>     return _bootstrap._gcd_import(name[level:], package, level)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
INTERNALERROR>   File "<frozen importlib._bootstrap_external>", line 940, in exec_module
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
INTERNALERROR>   File "/home/nicco/django-oscar-announcements/.venv/lib/python3.11/site-packages/pinax/announcements/__init__.py", line 1, in <module>
INTERNALERROR>     import pkg_resources
INTERNALERROR> ModuleNotFoundError: No module named 'pkg_resources'

Reproduce behavior

Hm. I cannot reproduce it here but I had issues with my test setup.
In a .venv, it became reproducible with all the dependencies I have.

Expected behavior
A clear and concise description of what you expected to happen.

This solved it: https://stackoverflow.com/a/79886564/1320237

The question is if the version can be retrieved an another way. I should check my other packages, too.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop

  • OS: Ubuntu
  • Version [e.g. 4.0.1]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions