setuptools removed pkg_resources. 1,504 PyPI packages still need it

Published 23 November 2026 · Data as of 13 November 2026

Scripts and results for this post on GitHub

PyPI code that still imports pkg_resourcesData as of 13 Nov 2026Projects that usepkg_resources2,759of 354,763 indexed projects1,504with an unguarded import intheir own codeReleased aftersetuptools 82 removedit1,408still use pkg_resources526with an unguarded importReady for a fix238unguarded, released in the last 6 months, with a public reposetuptools 82.0.0 (8 Feb 2026) removed pkg_resources. An unguarded import fails withModuleNotFoundError unless setuptools is pinned below 82.Latest release of 354,763 projects. py-code.org
PyPI code that still importspkg_resourcesData as of 13 Nov 2026Projects that use pkg_resources2,759of 354,763 indexedprojects1,504with an unguardedimport in theirown codeReleased after setuptools 82 removed it1,408still usepkg_resources526with an unguardedimportReady for a fix238unguarded, released in the last 6months, with a public reposetuptools 82.0.0 (8 Feb 2026) removedpkg_resources. An unguarded importfails with ModuleNotFoundError unlesssetuptools is pinned below 82.Latest release of 354,763 projects.py-code.org

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

QuestionAnswerKey number
How many PyPI projects use pkg_resources?2,759 of the 354,763 indexed projects1,408 of them released after setuptools 82
How many would fail without it?1,504 import it with no guard in their own code54.5%
How many are already safe?994 guard the import or try importlib first, and 88 pin setuptools below 821,082 projects
How many unguarded ones were released after the removal?526, including lm-eval, autogluon.multimodal and ydata-profiling526 projects
How many could take a fix today?Unguarded, released in the last six months and with a public repository238 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 setuptools since February gets a setuptools with no pkg_resources in it.
  • setuptools is not installed at all. Since Python 3.12, venv no longer installs setuptools into new environments, so pkg_resources is 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.metadata first and use pkg_resources only in the except block, 461 wrap the import in try or suppress(), 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 setuptools below 82 or pkg-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.
How the 2,759 projects that usepkg_resources import itprojectsUnguarded, top level1,305Unguarded, in function199Safe994Pinned or backport88Bundled copy only37Build scripts only20Tests or docs only116
The 2,759 PyPI projects whose latest release uses 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:

ProjectDownloads, 30 daysLatest releaseFirst unguarded importWhat fails without pkg_resources
pyinstaller4.61M2026-09-12PyInstaller/hooks/rthooks/pyi_rth_pkgres.py:44Nothing 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).
pbr1.57M2026-10-07pbr/_compat/metadata.py:89Nothing on Python 3.8 or later. pbr picks the pkg_resources branch only when neither importlib.metadata nor importlib_metadata can be imported.
pycairo1.27M2026-10-04cairo/__init__.py:24Only 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-eval0.41M2026-08-31lm_eval/tasks/leaderboard/ifeval/instructions_util.py:23The IFEval task module, which reads nltk's version with get_distribution() when it is imported.
cn2an0.20M2026-04-22cn2an/utils.py:4Only the helper module cn2an.utils. import cn2an does not load it.
autogluon.multimodal0.11M2026-09-18autogluon/multimodal/data/templates.py:16autogluon.multimodal.data.templates, which looks up its templates folder with resource_filename() when it is imported.
pyarmor0.09M2026-10-31pyarmor/packer.py:389Only the packer function that obfuscates dependency packages.
ydata-profiling0.08M2026-04-22ydata_profiling/profile_report.py:11import ydata_profiling. We installed 4.18.4 in a fresh Python 3.12 environment, and the import stopped with ModuleNotFoundError at this line.
rest.connector0.07M2026-11-03rest/connector/utils.py:2import rest.connector: its __init__.py imports a module that imports rest/connector/utils.py.
explainerdashboard0.04M2026-02-08explainerdashboard/dashboards.py:694Only dashboards whose explainer has more rows than the dropdown limit (1,000 by default), where it compares Dash versions with parse_version().
Most downloaded projects released aftersetuptools 82 with an unguardedpkg_resources importthousand downloads in 30 dayspyinstaller4,606pbr1,569pycairo1,271lm-eval413cn2an205autogluon.multimodal106pyarmor88ydata-profiling84rest.connector71explainerdashboard44
The ten most downloaded projects whose latest release came out after setuptools 82.0.0 (8 February 2026) and still has an unguarded 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:

ProjectDownloads, 30 daysLatest releaseFirst unguarded importWhat fails without pkg_resources
pytest-runner13.41M2023-12-04ptr/__init__.py:13import ptr, its only module, which the setup.py test command loads.
passlib3.03M2020-10-08passlib/pwd.py:16Only passlib.pwd, the password generator module.
nose1.79M2015-06-02nose/plugins/manager.py:378Nothing 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).
fs0.89M2022-05-02fs/__init__.py:4import fs: its __init__.py declares a namespace package with __import__("pkg_resources").
coreapi0.53M2017-10-05coreapi/utils.py:5import coreapi: its __init__.py imports coreapi.utils.
shodan0.43M2023-12-17shodan/__main__.py:33The shodan command-line tool. Both imports are in shodan/__main__.py.
gcloud0.39M2016-09-23gcloud/__init__.py:17import gcloud: the import is in its __init__.py.
formic20.37M2018-05-28formic/command.py:32The 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 nameProjects using itOf them unguardedReplacementSince
get_distribution955498importlib.metadata.version(name), or distribution(name)Python 3.8
resource_filename779516importlib.resources.files(package) / path, with as_file() for a real pathPython 3.9
DistributionNotFound477254importlib.metadata.PackageNotFoundErrorPython 3.8
require297194importlib.metadata.version() with packaging.specifiers.SpecifierSetPython 3.8
working_set285150importlib.metadata.distributions()Python 3.8
resource_string190122importlib.resources.files(package).joinpath(path).read_bytes()Python 3.9
iter_entry_points186108importlib.metadata.entry_points(group=...)Python 3.10 (group=)
declare_namespace16379a native namespace package (PEP 420): no __init__.pyPython 3.3
parse_version162119packaging.version.Versionpackaging (PyPI)
Requirement13498packaging.requirements.Requirementpackaging (PyPI)
resource_stream11865importlib.resources.files(package).joinpath(path).open('rb')Python 3.9
VersionConflict8449no direct replacement
pkg_resources names used by projects withan unguarded importprojectsresource_filename516get_distribution498DistributionNotFound254require194working_set150resource_string122parse_version119iter_entry_points108Requirement98declare_namespace79
The 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:

  1. 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.
  2. 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.
  3. Swap each call using the table above. Keep the change to pkg_resources alone, so it is quick to review.
  4. Test it where the old code fails: a fresh Python 3.12 or later virtual environment with setuptools>=82 or no setuptools at all. Run the project's own tests there.
  5. 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 .py file with Python's ast module, without running it. An import counts when it is import pkg_resources, from pkg_resources import …, __import__("pkg_resources") or importlib.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 try block with an ImportError, ModuleNotFoundError or Exception handler, in a with suppress(…) block with one of those, in an except block, under an if that tests the Python version, or under an if that checks whether pkg_resources is 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, tests and _tests folders, 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_party and node_modules count 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