r/PythonLearning • • 11m ago

Looking for a first open-source contribution? 238 maintained PyPI packages still import pkg_resources, and the fix is often one line

https://py-code.org/blog/pkg-resources-pypi/

setuptools 82 (February 2026) removed pkg_resources. Code that still runs import pkg_resources now fails with:

ModuleNotFoundError: No module named 'pkg_resources'

It also fails in any new Python 3.12+ virtual environment, because venv no longer installs setuptools.

I run py-code.org, a search over the code inside PyPI packages. I checked every package that still uses pkg_resources: 1,504 import it with no fallback, so they fail without it. 238 of them had a release in the last six months and have a public repository, so the maintainers are active and can merge a fix.

The fix is usually small, which makes it a good first pull request:

# before
import pkg_resources
requests_version = pkg_resources.get_distribution("requests").version

# after (Python 3.8+)
from importlib.metadata import version
requests_version = version("requests")

For data files inside a package, pkg_resources.resource_filename(pkg, path) becomes importlib.resources.files(pkg) / path (Python 3.9+).

How to do it:

  1. Pick a project from the list (CSV with the file and line of each import, and the repo link): https://github.com/pypi-data/blog/blob/main/pkg-resources-pypi/results/unguarded.csv
  2. Check that it isn't fixed already: search the repo's main branch for pkg_resources, and look at open issues and pull requests.
  3. Replace each call. The post has a table with the replacement for each pkg_resources function.
  4. Test in a fresh virtual environment (python3.12 -m venv), so setuptools isn't there, and run the project's tests.
  5. Open one small pull request. Explain it in one line: "pkg_resources was removed in setuptools 82 and isn't installed by default in Python 3.12+ virtual environments."

Please send one PR per project, and skip any project where someone has already opened one.

Full write-up, with the replacement table and the most downloaded affected packages: https://py-code.org/blog/pkg-resources-pypi/

2 Upvotes

0 comments sorted by