ModuleNotFoundError: No module named 'pkg_resources' in worker defaults on Python 3.13+

Open
#587 0 comments 0 reactions 1 assignee View on GitHub

@auvipy is already working on this.

Since Oct 31, 2026.

Assessment

This issue has not been assessed yet.

Description

bug

While testing a fix in celery/celery#10960, the smoke test worker container failed to start when running with Python 3.13+.

The worker crashes immediately on startup with the following traceback:

File "/app/app.py", line 13, in <module>
    from pytest_celery.vendors.worker.tasks import *
...
File "/usr/local/lib/python3.13/site-packages/pytest_celery/vendors/worker/defaults.py", line 7, in <module>
    from pkg_resources import resource_filename
ModuleNotFoundError: No module named 'pkg_resources'

Root cause:
Starting with Python 3.12 (and continuing in 3.13+), setuptools (which provides the pkg_resources module) is no longer installed by default in official Python Docker images. Since pytest_celery/vendors/worker/defaults.py imports pkg_resources, the worker container fails to boot in modern Python environments.

Suggested fix:
Replace pkg_resources.resource_filename with importlib.resources.files (or importlib_resources for backward compatibility), which is the modern standard for accessing package data in Python.


As requested by @auvipy in celery/celery#10960, I'm opening this issue so you can track the fix here. Let me know if you need any more details!

Dominant language
Python
Stars
83
Forks
18
Avg merge
4h 13m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from celery/pytest-celery

All issues in celery/pytest-celery

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.