setuptools removed pkg_resources. 1,504 PyPI packages still need it
Scripts and results for this post on GitHub
setuptools 82.0.0, released on 8 February 2026, removed pkg_resources. Code that runs import pkg_resources now stops with ModuleNotFoundError: No module named 'pkg_resources' unless an older setuptools is installed. Nine months later, 2,759 PyPI projects still use it in their latest release.
py-code.org reads the code in the latest release of 354,763 PyPI projects. We downloaded the release of every project that uses pkg_resources and checked each import: whether it would fail, or whether the code guards it or falls back to importlib.metadata. The list of projects whose import would fail is public, with the file and line of each import, so anyone can send the maintainers a fix.
The short answer
| Question | Answer | Key number |
|---|---|---|
How many PyPI projects use pkg_resources? | 2,759 of the 354,763 indexed projects | 1,408 of them released after setuptools 82 |
| How many would fail without it? | 1,504 import it with no guard in their own code | 54.5% |
| How many are already safe? | 994 guard the import or try importlib first, and 88 pin setuptools below 82 | 1,082 projects |
| How many unguarded ones were released after the removal? | 526, including lm-eval, autogluon.multimodal and ydata-profiling | 526 projects |
| How many could take a fix today? | Unguarded, released in the last six months and with a public repository | 238 projects |
Verdict: just over half of the projects that still use pkg_resources would fail without it. 1,504 of the 2,759 import it with no guard, and 526 of those shipped a release after setuptools removed it. The fix is usually a one-line swap to importlib.metadata or importlib.resources, so these are good first pull requests. The full list is in the results folder.
What changed: setuptools 82 removed pkg_resources
pkg_resources shipped inside setuptools for years. It found installed packages, read their versions and entry points, and opened data files that packages ship. The setuptools 82.0.0 changelog says it "has been removed from Setuptools". It points to importlib.resources and importlib.metadata for most uses, and says projects that still need pkg_resources "should depend on older versions of setuptools".
An unguarded import pkg_resources fails in two common setups:
- setuptools 82 or later is installed. Any
pip install --upgrade setuptoolssince February gets a setuptools with nopkg_resourcesin it. - setuptools is not installed at all. Since Python 3.12,
venvno longer installs setuptools into new environments, sopkg_resourcesis not there by default (What's New in Python 3.12). This was already true before setuptools 82.
Key point: pinning setuptools<82 keeps old code running, and the changelog recommends it for projects that need pkg_resources. A pin in [build-system] only covers the build, though. Code that imports pkg_resources at run time needs setuptools below 82 in the environment where it runs.
There is also pkg-resources-backport, a third-party package first released on 19 February 2026. Its description calls it a "snapshot of last pkg_resources module from setuptools", and it installs a top-level pkg_resources module. OpenStack's CI was one of the first to break: its mailing list thread is titled "setuptools v82.0.0 breaks a bunch of things by removing pkg_resources" (openstack-discuss).
1,504 of 2,759 projects would fail without pkg_resources
For each project, we looked at every pkg_resources import in its own code (not tests, docs or setup.py) and kept the riskiest one:
- 1,305 import it at the top of a file. Importing that file fails, and when the file is the package's
__init__.py, so does importing the package. - 199 import it inside a function. Only the code that calls that function fails.
- 994 are safe. 424 try
importlib.metadatafirst and usepkg_resourcesonly in theexceptblock, 461 wrap the import intryorsuppress(), 118 import it only on old Pythons, and 10 only when another package has already loaded it. A project can count in more than one of these. - 88 are covered by a dependency: they require
setuptoolsbelow 82 orpkg-resources-backport. - 37 have it only in a bundled copy of another library, such as an old Jinja2 inside Nuitka, and 20 only in build scripts.
pkg_resources, by the riskiest import in their own code. The counts come from parsing the code, not from running it.Why: many projects began moving years ago, while pkg_resources was only deprecated. The most common safe pattern is try: from importlib.metadata import version with pkg_resources in the except ImportError block. That code never reaches the fallback on Python 3.8 or later, so it works with setuptools 82.
526 unguarded projects shipped a release after the removal
526 of the 1,504 unguarded projects uploaded their latest release after 8 February 2026, so they are maintained and could take a fix in the next release. The table shows the most downloaded of them. We read each import by hand, because a rule cannot tell a hook that only runs for pkg_resources users from an import that breaks the package:
| Project | Downloads, 30 days | Latest release | First unguarded import | What fails without pkg_resources |
|---|---|---|---|---|
pyinstaller | 4.61M | 2026-09-12 | PyInstaller/hooks/rthooks/pyi_rth_pkgres.py:44 | Nothing in normal use. The file is a runtime hook that PyInstaller adds only to apps that bundle pkg_resources (its rthooks.dat maps it to that module). |
pbr | 1.57M | 2026-10-07 | pbr/_compat/metadata.py:89 | Nothing on Python 3.8 or later. pbr picks the pkg_resources branch only when neither importlib.metadata nor importlib_metadata can be imported. |
pycairo | 1.27M | 2026-10-04 | cairo/__init__.py:24 | Only cairo.get_include(), and only when the include folder is not next to the package, the case the code comments as an .egg install. |
lm-eval | 0.41M | 2026-08-31 | lm_eval/tasks/leaderboard/ifeval/instructions_util.py:23 | The IFEval task module, which reads nltk's version with get_distribution() when it is imported. |
cn2an | 0.20M | 2026-04-22 | cn2an/utils.py:4 | Only the helper module cn2an.utils. import cn2an does not load it. |
autogluon.multimodal | 0.11M | 2026-09-18 | autogluon/multimodal/data/templates.py:16 | autogluon.multimodal.data.templates, which looks up its templates folder with resource_filename() when it is imported. |
pyarmor | 0.09M | 2026-10-31 | pyarmor/packer.py:389 | Only the packer function that obfuscates dependency packages. |
ydata-profiling | 0.08M | 2026-04-22 | ydata_profiling/profile_report.py:11 | import ydata_profiling. We installed 4.18.4 in a fresh Python 3.12 environment, and the import stopped with ModuleNotFoundError at this line. |
rest.connector | 0.07M | 2026-11-03 | rest/connector/utils.py:2 | import rest.connector: its __init__.py imports a module that imports rest/connector/utils.py. |
explainerdashboard | 0.04M | 2026-02-08 | explainerdashboard/dashboards.py:694 | Only dashboards whose explainer has more rows than the dropdown limit (1,000 by default), where it compares Dash versions with parse_version(). |
pkg_resources import, with their downloads in the 30 days before the scan.Old packages that still get downloads: pytest-runner, passlib and fs
The other 978 unguarded projects have not had a release since setuptools 82, and 710 of them have had no release in two years. The most downloaded:
| Project | Downloads, 30 days | Latest release | First unguarded import | What fails without pkg_resources |
|---|---|---|---|---|
pytest-runner | 13.41M | 2023-12-04 | ptr/__init__.py:13 | import ptr, its only module, which the setup.py test command loads. |
passlib | 3.03M | 2020-10-08 | passlib/pwd.py:16 | Only passlib.pwd, the password generator module. |
nose | 1.79M | 2015-06-02 | nose/plugins/manager.py:378 | Nothing from pkg_resources: nose uses this plugin manager only after its own guarded import of pkg_resources succeeds. nose fails on Python 3.12 for another reason, its use of the removed imp module (see our post on removed modules). |
fs | 0.89M | 2022-05-02 | fs/__init__.py:4 | import fs: its __init__.py declares a namespace package with __import__("pkg_resources"). |
coreapi | 0.53M | 2017-10-05 | coreapi/utils.py:5 | import coreapi: its __init__.py imports coreapi.utils. |
shodan | 0.43M | 2023-12-17 | shodan/__main__.py:33 | The shodan command-line tool. Both imports are in shodan/__main__.py. |
gcloud | 0.39M | 2016-09-23 | gcloud/__init__.py:17 | import gcloud: the import is in its __init__.py. |
formic2 | 0.37M | 2018-05-28 | formic/command.py:32 | The formic command-line tool in formic/command.py. |
For these, a pull request may never be released. If your project depends on one, the fix is on your side: pin setuptools<82 where it runs, or replace the package.
Which pkg_resources calls they use, and what replaces each
The index records each name a project uses, such as pkg_resources.get_distribution. The table counts projects per name, and gives the replacement from the importlib_metadata and importlib_resources migration guides and the setuptools page on pkg_resources:
| pkg_resources name | Projects using it | Of them unguarded | Replacement | Since |
|---|---|---|---|---|
get_distribution | 955 | 498 | importlib.metadata.version(name), or distribution(name) | Python 3.8 |
resource_filename | 779 | 516 | importlib.resources.files(package) / path, with as_file() for a real path | Python 3.9 |
DistributionNotFound | 477 | 254 | importlib.metadata.PackageNotFoundError | Python 3.8 |
require | 297 | 194 | importlib.metadata.version() with packaging.specifiers.SpecifierSet | Python 3.8 |
working_set | 285 | 150 | importlib.metadata.distributions() | Python 3.8 |
resource_string | 190 | 122 | importlib.resources.files(package).joinpath(path).read_bytes() | Python 3.9 |
iter_entry_points | 186 | 108 | importlib.metadata.entry_points(group=...) | Python 3.10 (group=) |
declare_namespace | 163 | 79 | a native namespace package (PEP 420): no __init__.py | Python 3.3 |
parse_version | 162 | 119 | packaging.version.Version | packaging (PyPI) |
Requirement | 134 | 98 | packaging.requirements.Requirement | packaging (PyPI) |
resource_stream | 118 | 65 | importlib.resources.files(package).joinpath(path).open('rb') | Python 3.9 |
VersionConflict | 84 | 49 | no direct replacement |
pkg_resources names most used by the 1,504 projects with an unguarded import. A project that uses several names counts once for each.The most common fix is a one-line change. pkg_resources.get_distribution("name").version becomes importlib.metadata.version("name"), and pkg_resources.DistributionNotFound becomes importlib.metadata.PackageNotFoundError. Both arrived in Python 3.8. For data files, importlib.resources.files(package) arrived in Python 3.9. Projects that support older Pythons can use the importlib_metadata and importlib_resources backports from PyPI.
Tip: resource_filename() returned a path on disk. files() returns a path-like object that can sit inside a zip file. When the code needs a real file path, for example to pass to a C library, wrap it: with importlib.resources.as_file(files(package) / "data.bin") as path:.
How to send a fix
If a project you use is on the list, a small pull request is often all it needs. These steps keep it useful for the maintainers:
- Find a project. Search pkg_resources on py-code.org, or open unguarded.csv. The CSV lists every unguarded project with its downloads, last release, the file and line of each import, and its repository when PyPI names one. The live search is rebuilt every week, so its counts can differ from this post.
- Check that it is not fixed already. Our data is the latest release on PyPI, not the main branch. Search the repository's main branch for
pkg_resources, and its open issues and pull requests. - Swap each call using the table above. Keep the change to
pkg_resourcesalone, so it is quick to review. - Test it where the old code fails: a fresh Python 3.12 or later virtual environment with
setuptools>=82or no setuptools at all. Run the project's own tests there. - Explain it in one line, for example: "pkg_resources was removed in setuptools 82 and is not installed by default in Python 3.12+ virtual environments."
One focused pull request per project is enough. Skip archived repositories, and do not open a second pull request where someone already sent one.
Find them yourself with DuckDB
The index is on Hugging Face. This query lists the most downloaded projects that use pkg_resources and had a release after setuptools 82. The dataset is rebuilt every week, so today's output differs from this post's. It counts every use, including guarded ones, so it lists more projects than the unguarded count:
SELECT p.project,
p.downloads_30d,
CAST(p.upload_time AS DATE) AS last_release,
string_agg(DISTINCT r.name, ', ' ORDER BY r.name) AS names_used
FROM 'hf://datasets/pypi-data/py-code/refs.parquet' r JOIN 'hf://datasets/pypi-data/py-code/projects.parquet' p USING (project)
WHERE r.module = 'pkg_resources'
AND r.name LIKE 'pkg\_resources.%' ESCAPE '\'
AND p.project <> 'setuptools'
AND p.upload_time >= '2026-02-08'
GROUP BY ALL
ORDER BY p.downloads_30d DESC
LIMIT 10;
On the 13 November 2026 data it returned:
┌────────────────────┬───────────────┬──────────────┬──────────────────────────────────────────────────────────────────┐ │ project │ downloads_30d │ last_release │ names_used │ │ varchar │ int64 │ date │ varchar │ ├────────────────────┼───────────────┼──────────────┼──────────────────────────────────────────────────────────────────┤ │ pytest │ 417319664 │ 2026-10-27 │ pkg_resources._namespace_packages, pkg_resources.fixup_namespac… │ │ pytz │ 220681293 │ 2026-10-29 │ pkg_resources.resource_stream │ │ grpcio-tools │ 122158802 │ 2026-10-30 │ pkg_resources.resource_filename │ │ onnxruntime │ 71790362 │ 2026-10-26 │ pkg_resources.working_set │ │ sentry-sdk │ 66717863 │ 2026-11-12 │ pkg_resources.working_set │ │ Werkzeug │ 37350057 │ 2026-09-27 │ pkg_resources.working_set │ │ litellm │ 31988815 │ 2026-11-12 │ pkg_resources.resource_filename │ │ redshift-connector │ 22126670 │ 2026-10-08 │ pkg_resources.get_distribution │ │ ansible-core │ 13052321 │ 2026-11-02 │ pkg_resources.Requirement, pkg_resources.Requirement.parse │ │ ansible │ 6630112 │ 2026-11-04 │ pkg_resources.DistributionNotFound, pkg_resources.get_distribut… │ └────────────────────┴───────────────┴──────────────┴──────────────────────────────────────────────────────────────────┘ 10 rows 4 columns
None of these ten would fail without pkg_resources. Our check found the imports in pytest, pytz, grpcio-tools, sentry-sdk, Werkzeug, litellm, redshift-connector, ansible-core and ansible guarded, in a fallback or behind a check, and the only unguarded ones in onnxruntime are in benchmark scripts. That is why the counts in this post come from reading each import, not from the names alone.
The scripts behind every number in this post, including the one that downloads each release and labels each import, are in the pypi-data/blog repository with their results.
How the numbers were counted
- Which projects. The index holds the latest release of 354,763 projects: every project released between 13 November 2025 and 13 November 2026, plus the 60,000 most downloaded projects even when their latest release is older. For each project it reads one file: a pure-Python wheel, then a platform wheel, then the source distribution. setuptools itself is left out.
- Which imports. We downloaded the same file again for all 2,759 projects and parsed every
.pyfile with Python'sastmodule, without running it. An import counts when it isimport pkg_resources,from pkg_resources import …,__import__("pkg_resources")orimportlib.import_module("pkg_resources"). The index finds projects by their names, and it does not follow__import__(), so a project whose only use is an__import__("pkg_resources")line is missing from the count. - Guarded. An import is safe when it sits in a
tryblock with anImportError,ModuleNotFoundErrororExceptionhandler, in awith suppress(…)block with one of those, in anexceptblock, under anifthat tests the Python version, or under anifthat checks whetherpkg_resourcesis already loaded. This is a rule, not a test: an unguarded import in a file that never loads counts as unguarded, and so does one in a branch that a setting turns off. - Own code. Files under
test,testsand_testsfolders,conftest.py,setup.py, docs, examples and benchmark scripts do not count as the project's own code. Files under folders such as_vendor,vendored,inline_copy,third_partyandnode_modulescount as bundled copies. - Dates. "After the removal" means the release was uploaded on or after 8 February 2026, when setuptools 82.0.0 was uploaded to PyPI. "Released in the last six months" means on or after 13 May 2026.
- Downloads. Download counts are for the 30 days before the scan, from ClickHouse's public PyPI dataset, and exist only for the 60,000 most downloaded projects.
Frequently asked questions
Why do I get ModuleNotFoundError: No module named 'pkg_resources'?
Some code in your environment, yours or a dependency's, imports pkg_resources. setuptools 82.0.0, released on 8 February 2026, removed it, and since Python 3.12 venv no longer installs setuptools at all. In either environment an unguarded import pkg_resources fails.
Is pkg_resources deprecated or removed?
It is removed. setuptools 82.0.0 no longer contains pkg_resources, and its changelog says projects that still need it should depend on older versions of setuptools.
What replaces pkg_resources?
importlib.metadata replaces it for package versions, installed distributions and entry points, and importlib.resources for data files inside a package. Version and requirement parsing move to the packaging library.
What replaces pkg_resources.get_distribution?
importlib.metadata.version("name") returns the installed version, and importlib.metadata.PackageNotFoundError replaces DistributionNotFound. Both are in the standard library since Python 3.8.
How do I fix the error without changing the code?
Install setuptools below 82 in the environment where the code runs, or install pkg-resources-backport, a third-party snapshot of the last pkg_resources. A setuptools pin in the build-system table of pyproject.toml only covers the build, not the running code.
How many PyPI packages still use pkg_resources?
2,759 of the 354,763 projects in the py-code.org index use it in their latest release. 1,504 of them import it with no guard and would fail without it, and 526 of those were released after setuptools 82.
Sources
- py-code.org dataset on Hugging Face, data as of 13 November 2026 (rebuilt weekly)
- pypi-data/blog, the scripts and results for this post
- setuptools history: v82.0.0 (February 2026)
- setuptools: package discovery and resource access using pkg_resources
- What's New in Python 3.12: setuptools no longer installed in
venvenvironments - importlib_metadata migration guide and importlib_resources migration guide
- Python documentation: importlib.metadata and importlib.resources
- pkg-resources-backport on PyPI
- openstack-discuss: setuptools v82.0.0 breaks a bunch of things by removing pkg_resources (February 2026)
- discuss.python.org: pkg_resources removal, how to go from there?
- ClickHouse PyPI downloads (ClickPy)