Blog · Generative AI ·
No module named 'pkg_resources': setuptools 82 removed it, here is the fix
By Khadim Hussain · 5 min read
In short
ModuleNotFoundError: No module named 'pkg_resources' means the environment has setuptools 82 or later, or no setuptools at all. Setuptools 82.0.0, released on 8 February 2026, removed pkg_resources. The quick fix is pip install "setuptools<82" in that environment; if the import is in your own code, replace it with importlib.resources, importlib.metadata and packaging, which give the same results. Some libraries hide the error: Chatterbox TTS fails with TypeError: 'NoneType' object is not callable at perth.PerthImplicitWatermarker() for this reason. I reproduced both and tested the fixes on Windows 11 with Python 3.12 on 20 November 2026.
Contents
ModuleNotFoundError: No module named 'pkg_resources' started showing up across Python projects in 2026 because setuptools no longer ships that module. I hit it through Chatterbox, an open text-to-speech model I was testing for the narration on my YouTube channel, Khadim Labs, where it doesn't even mention pkg_resources. Below are the cause, two fixes I tested, and that Chatterbox variant. I reproduced everything on 20 November 2026 on Windows 11 with Python 3.12.10.
Quick fix
In the same environment as the failing program, run pip install "setuptools<82", then start a new Python process. Keep the quotes: in Windows Command Prompt, pip install setuptools<82 without them fails with "The system cannot find the file specified", because cmd reads <82 as an input file. If the import pkg_resources is in your own code, replace it instead.
Why is pkg_resources missing?
pkg_resources was part of setuptools, and setuptools 82.0.0, released on 8 February 2026, removed it: "pkg_resources has been removed from Setuptools." The changelog points to importlib.resources and importlib.metadata as the replacements and says projects that still rely on it "should depend on older versions of setuptools".
So the error means one of two things: the environment has setuptools 82 or later, or it has no setuptools at all. Both got more common on Python 3.12, where venv stopped installing setuptools into new environments. Setuptools then only arrives as another package's dependency, and pip installs the newest one unless something caps it. In my case that package was torch 2.6.0, which declares setuptools; python_version >= "3.12" with no upper bound, and the environment ended up with setuptools 84.2.1.
Check your setuptools version
Run these with the same Python that throws the error:
python -c "import setuptools; print(setuptools.__version__)"
python -c "import pkg_resources"On my broken environment the first printed 84.2.1 and the second ended in ModuleNotFoundError: No module named 'pkg_resources'. If the first command fails too, setuptools isn't installed at all, and the fix below installs a version that has pkg_resources.
Fix 1: pin setuptools below 82
pip install "setuptools<82"pip picked setuptools 81.0.0, and the import worked again. Each import now prints a warning, which is expected:
UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.Put the pin in requirements.txt or pyproject.toml next to the package that needs it. Otherwise the next pip install --upgrade of anything that depends on setuptools brings 82 or later back, and the error with it.
Fix 2: replace pkg_resources in your own code
If the import is in code you control, move off pkg_resources instead of pinning. These are the three calls I see most often, with the replacements. I ran each pair side by side and they returned the same results:
| pkg_resources | Replacement | Comes from |
|---|---|---|
pkg_resources.resource_filename("mypkg", "data.bin") | str(importlib.resources.files("mypkg") / "data.bin") | Python's standard library |
pkg_resources.get_distribution("name").version | importlib.metadata.version("name") | Python's standard library |
pkg_resources.parse_version("1.0.10") | packaging.version.Version("1.0.10") | the packaging package (pip install packaging) |
importlib.resources.files returns a path object (a pathlib.Path for a normally installed package); wrap it in str() where the old code expected a string. For a package that isn't installed, importlib.metadata.version raises PackageNotFoundError, which you can catch the same way you caught DistributionNotFound before.
What "pkg_resources is deprecated as an API" means
That is the warning above, and it's only a warning: your program keeps running. Setuptools 81.0.0 printed it as soon as Chatterbox's watermark library imported pkg_resources. It's the heads-up for the removal, so on 82 or later the same import becomes the ModuleNotFoundError. To get rid of the warning for good, the import has to go, through Fix 2 or a release of the library that uses it.
Chatterbox: "'NoneType' object is not callable" is the same error
Some libraries catch the ImportError and carry on, and then the message you get has nothing to do with pkg_resources. Chatterbox, Resemble AI's open text-to-speech model, is one. On my machine (chatterbox-tts 0.1.7, resemble-perth 1.0.1, torch 2.6.0 on the CPU), loading Chatterbox-Turbo ended like this, with the path to the virtual environment shortened to <venv>:
File "<venv>\Lib\site-packages\chatterbox\tts_turbo.py", line 183, in from_local
return cls(t3, s3gen, ve, tokenizer, device, conds=conds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<venv>\Lib\site-packages\chatterbox\tts_turbo.py", line 130, in __init__
self.watermarker = perth.PerthImplicitWatermarker()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not callableChatterbox marks the audio it generates with Resemble AI's Perth watermark, and Perth's __init__.py loads the watermarker like this:
try:
from .perth_net.perth_net_implicit.perth_watermarker import PerthImplicitWatermarker
except ImportError:
PerthImplicitWatermarker = NoneThe first line of perth/perth_net/__init__.py is from pkg_resources import resource_filename. On setuptools 82 or later that import fails, the except turns the class into None, and Chatterbox only notices when it calls it. ChatterboxTTS, ChatterboxMultilingualTTS and ChatterboxVC create the same watermarker in their constructors, so all of them fail the same way. Someone filed the swallowed import as Perth issue #23 on 3 November 2026.
To confirm it's this, run python -c "import perth; print(perth.PerthImplicitWatermarker)" in the Chatterbox environment. None means you have this bug, and Fix 1 solves it: with setuptools 81.0.0, the same call printed "loaded PerthNet (Implicit) at step 250,000" and model.watermarker was a real PerthImplicitWatermarker.
For Chatterbox there is a second fix that needs no pin. Perth's GitHub master replaced the pkg_resources import with importlib.resources in December 2025 (Perth PR #11), but no release has reached PyPI since 1.0.1. Chatterbox's pyproject.toml on GitHub points Perth at that master branch, while the chatterbox-tts package on PyPI only asks for resemble-perth>=1.0.0, so pip install chatterbox-tts gets the old Perth and an install from Chatterbox's source doesn't. Installing Perth from GitHub into the same environment worked in my test with setuptools 84.2.1 and no pkg_resources at all: it came in as resemble-perth 1.1.0, and Chatterbox-Turbo loaded with the real watermarker.
pip install "git+https://github.com/resemble-ai/Perth.git@master"That version also lists pydub and PyYAML as dependencies, which pip adds if they're missing.
I would skip the other fixes going around. Swapping in perth.DummyWatermarker stops the error, and the open chatterbox PR #469 does that as a fallback, but Perth's own source describes DummyWatermarker as a placeholder that "doesn't actually embed or extract real watermarks"; its apply_watermark only rounds the samples to five decimal places. Upgrading from PyPI doesn't help yet either: chatterbox-tts 0.1.7 (26 March 2026) and resemble-perth 1.0.1 (23 May 2025) are the newest releases there, chatterbox issue #198 has been open since July 2025, and Perth PR #24, which would raise the real ImportError, is unmerged.
Audio watermarks like Perth's are one way to tell generated media from real recordings. Google runs its own for images, video and audio, and I tested how well Google's SynthID check recognizes Gemini images after a screenshot or a re-save.
If you are tuning or shipping open models and want them tested against a baseline before they reach users, that is my LLM fine-tuning service.
Next
Related
LLM Fine-tuning · · 10 min read
Ollama no longer supports LoRA adapters: how to run a fine-tune now
Ollama 0.34.1 removed the Modelfile ADAPTER instruction. The exact errors, and two tested ways to run a LoRA fine-tune: a merged GGUF or llama.cpp --lora.
Generative AI · · 9 min read
Is SynthID reliable? I tested Google's AI image check on screenshots, stripped files and real photos
Gemini images, a screenshot, a stripped file, a real photo and a composite, run through Google's SynthID check: what it caught, what it missed, and C2PA.
Unsloth and QLoRA fine-tuning consultant for open LLMs
LLM fine-tuning consultant: I fine-tune open models with Unsloth and QLoRA, test them against a baseline, and ship them for Ollama, vLLM or Transformers.
Frequently asked questions
Which setuptools version removed pkg_resources?
Setuptools 82.0.0, released on 8 February 2026. Its changelog says pkg_resources has been removed and that projects relying on it should depend on older versions of setuptools. Version 81.0.0, released two days earlier, still includes it.
Is pinning setuptools below 82 safe?
It's a stopgap that works: every release before 82 still has pkg_resources. You get a UserWarning that pkg_resources is deprecated when something imports it, and you stay on an older setuptools until the package that needs pkg_resources moves off it.
Should I pin setuptools below 81 or below 82?
Below 82 is enough. The deprecation warning itself suggests pinning below 81, which is why you'll see both pins in answers online; either one gives you a setuptools that still contains pkg_resources.
Why do I get this on Python 3.12 but not on older Python?
Since Python 3.12, venv no longer installs setuptools into new environments. Setuptools then only arrives as some package's dependency, and pip picks the newest version unless something caps it. torch 2.6.0, for example, requires setuptools on Python 3.12 and later with no upper bound.
Why does Chatterbox say 'NoneType' object is not callable?
Chatterbox creates a Perth watermarker when a model loads. Perth imports that class inside a try block and sets it to None when the import fails, and the import fails because Perth needs pkg_resources. Pinning setuptools below 82 fixes it and keeps the real watermark, and so does installing Perth from GitHub, where that import was replaced in December 2025.
Does upgrading Chatterbox fix the NoneType error?
Not from PyPI, as of 20 November 2026. The chatterbox-tts 0.1.7 package asks for resemble-perth 1.0.0 or later, and the newest Perth on PyPI is still 1.0.1, which imports pkg_resources. Perth's GitHub master replaced that import in December 2025 (PR #11), and pip install "git+https://github.com/resemble-ai/Perth.git@master" fixed it in my test with setuptools 84.2.1.
Want a second pair of eyes on this?
Book a 15-minute intro call. Bring the problem, and you leave with a concrete next step.