Skip to content
Nilay Kabariya

Entry No.082·Fixes·Updated ·3 min read

No module named 'pkg_resources': setuptools 82 removed it

Installing setuptools no longer fixes it: setuptools 82 dropped pkg_resources, and 3.12+ venvs ship without setuptools. Tested with pip, uv and TensorBoard.

The error, verbatim

Jump to the fix ↓
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
✓ Reproduced on Windows 11 Pro; Ubuntu on GitHub Actions

Tested on

Python
3.14.5 and 3.10.11
setuptools
80.10.2, 81.0.0, 82.0.0, 84.2.0
Installers
pip 26.2.1, uv 0.13.3
Re-run
November 3: Python 3.14.9, setuptools up to 84.2.1, pip 26.2.2, uv 0.13.7, TensorBoard 2.21.0 (Linux)
OS
Windows 11 Pro; Ubuntu on GitHub Actions

✓ Last re-run on GitHub Actions · see the run · all repros

Contents
  1. A package you use imports it01
  2. pip install fails while building a package02
  3. Your own code imports it03
  4. uv environments04
  5. Where and how I checked it05

pkg_resources was never part of Python. It came with setuptools, and two separate changes took it away:

  1. Python 3.12 stopped putting setuptools into new virtual environments. A fresh 3.14 venv had only pip in it, and import pkg_resources failed right away. A uv venv didn’t have setuptools either.
  2. setuptools removed pkg_resources in version 82.0.0 (February 2026). So the answer you’ll find everywhere, “install setuptools”, now installs a setuptools without it.

I checked each version in the same venv:

setuptools import pkg_resources
none (fresh 3.14 venv) No module named 'pkg_resources'
80.10.2 works, with a deprecation warning
81.0.0 works, with the same warning
82.0.0 No module named 'pkg_resources'
84.2.0 (latest, what pip install setuptools gives you) No module named 'pkg_resources'

The warning on 80 and 81 says pin to Setuptools<81, but 81.0.0 still had the module. The cut is at 82.

Where the import comes from decides the fix. It’s usually one of three places: your own code, a package you installed, or a package being built from source during pip install.

A package you use imports it

First, try upgrading that package. Newer releases often no longer import it.

TensorBoard is a common case. 2.15.2 imports pkg_resources in tensorboard/default.py, and with setuptools 84.2.0, tensorboard --version failed with this error. Upgrading fixed it:

pip install -U tensorboard

If you can’t upgrade the package, pin setuptools below 82 in the same environment:

pip install "setuptools<82"

pip install fails while building a package

If the error shows up during pip install, under Getting requirements to build wheel, the package’s own setup.py imports pkg_resources. I reproduced it with a small package:

  error: subprocess-exited-with-error
  ModuleNotFoundError: No module named 'pkg_resources'
ERROR: Failed to build 'file:///D:/nk-pkgres/oldpkg' when getting requirements to build wheel

pip builds the package in a separate, temporary environment with the latest setuptools, so installing an older setuptools in your own environment doesn’t change anything.

Tell pip which setuptools to use for the build:

echo "setuptools<82" > build-constraints.txt
pip install --build-constraint build-constraints.txt your-package

With uv, the flag is the same:

uv pip install --build-constraint build-constraints.txt your-package

Another option: install "setuptools<82" and wheel into your environment, then run pip install --no-build-isolation your-package. That worked too, but it builds with whatever happens to be installed in your environment.

Your own code imports it

Replace it with the standard library. The most common use, reading an installed package’s version:

import importlib.metadata

importlib.metadata.version("pip")

For resource files and entry points, the setuptools page on pkg_resources points to importlib.resources and importlib.metadata. Until you’ve moved over, "setuptools<82" in your requirements keeps the old code running.

uv environments

uv venv creates an environment without setuptools, so anything that imports pkg_resources fails there first. Adding setuptools with uv pip install setuptools gave 84.2.0, which still failed.

uv pip install "setuptools<82"

Where and how I checked it

Windows 11 Pro, Python 3.14.5 and 3.10.11, October 20, 2026. Fresh venvs from py -m venv and uv venv (uv 0.13.3), with setuptools 80.10.2, 81.0.0, 82.0.0 and 84.2.0. A one-file package whose setup.py imports pkg_resources was installed with pip 26.2.1 and uv, with and without build constraints. TensorBoard 2.15.2 and 2.21.0 ran on Python 3.10. Every message above is the real output.

Re-checked on November 3, 2026 on Linux (GitHub Actions ubuntu-latest, Python 3.14.9), with a fresh venv for every setuptools version. 80.10.2 and 81.0.0 still imported pkg_resources with a deprecation warning; 82.0.0, 83.0.0 and 84.2.1 had no pkg_resources folder and failed. TensorBoard 2.15.2 failed with the latest setuptools and hit the NumPy AttributeError with setuptools<82, while TensorBoard 2.21.0 ran with setuptools 84.2.1. The setup.py package failed in pip 26.2.2 and uv 0.13.7 until --build-constraint was added, PIP_CONSTRAINT still didn’t reach the build, and importlib.metadata worked with no setuptools at all. The script and the run are public.

— N.K., end of entry No.082

Useful? Pass it on:Post on XFollow @EmotionalMatter

Related entries

  1. No.070

    No module named 'distutils' on Python 3.12+ (node-gyp, setuptools)

    Python 3.12 removed distutils. setuptools brings it back for Python code; npm installs need a newer npm (node-gyp 10+); msvccompiler needs setuptools below 74.

    > ModuleNotFoundError: No module named 'distutils'

    FIXED3 min
  2. No.094

    Python CERTIFICATE_VERIFY_FAILED, tested on 3.12 to 3.15

    certificate verify failed: unable to get local issuer certificate, or Basic Constraints of CA cert not marked critical on Python 3.13+. Each cause tested.

    > requests.exceptions.SSLError: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/

    FIXED3 minWindows
  3. No.083

    ModuleNotFoundError: No module named X, but it's installed

    pip installed it into one Python and your code runs another: a venv not activated, a Jupyter kernel, a second Python. Five cases reproduced, and the check.

    > Traceback (most recent call last):

    FIXED3 min
  4. No.075

    Python was not found, or pip not recognized (Windows fix)

    "Python was not found" comes from a Microsoft Store placeholder python.exe, not Python, and exits with 9009. How to see which python.exe wins, and the pip fix.

    > Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Apps > Advanced app settings > App execution aliases.

    FIXED3 minWindows

Post card · Every Sunday

What broke this week.

One email on Sundays: the Node, TypeScript, Python and AI SDK releases that broke builds that week, each one reproduced, with a link to the fix that worked. Never shared, and you can leave any time.

— Nilay

or follow by RSSor on X

By subscribing you agree to the privacy note. One click to leave.

tip: paste the exact error text