UserWarning: pkg_resources is deprecated as an API (tested fixes)
UserWarning: pkg_resources is deprecated as an API means something imports pkg_resources, which setuptools 82.0.0 removed. Tested below: the warning, the error it turns into, finding the importer, and silencing it with warnings.filterwarnings or PYTHONWARNINGS.
1. The warning
With setuptools 81.0.0 on Python 3.11.17, a one-line b1.py:
import pkg_resources
print("loaded")
$ python b1.py
b1.py:1: 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.
import pkg_resources
loaded
It is only a warning, and the import still works. But it means the code (yours, or the library named in the warning's file path) will break on newer setuptools. With setuptools 84.2.1 the same script fails:
$ python b1.py
Traceback (most recent call last):
File "b1.py", line 1, in <module>
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
That is the error covered in No module named 'pkg_resources'. setuptools 82.0.0 removed the module.
2. Find who imports it
The file path in the warning tells you the importer. If it is in site-packages/<library>/, upgrading that library is the real fix, if a fixed release exists. fs 2.4.16 has none, see import fs:
/path/to/venv/lib/python3.11/site-packages/fs/__init__.py:4: 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.
That line came from setuptools 80.10.2, so pinning setuptools<81, as the message suggests, keeps pkg_resources working but does not hide the warning.
3. Silence it (tested)
In code, before the import:
import warnings
warnings.filterwarnings("ignore", message="pkg_resources is deprecated as an API")
import pkg_resources
print("loaded, no warning")
$ python b2.py
loaded, no warning
Or from outside, without touching code:
$ PYTHONWARNINGS="ignore:pkg_resources is deprecated as an API" python b1.py
loaded
Silencing only hides the warning. If your own code uses pkg_resources, move to importlib.metadata (versions, entry points) and importlib.resources (package data) before you upgrade to setuptools 82 or newer.
Related: pygame version of this warning · Home Assistant · No module named 'pkg_resources' (general fix) · docker build · tensorboard.
Frequently asked questions
Does pinning setuptools<81 remove the warning?
No. setuptools 80.10.2 still printed it in our test. The pin keeps pkg_resources importable, since 82.0.0 removed it, but the warning remains.
Is the warning harmful?
No, the import still works on setuptools 81. But on setuptools 82 or newer the same import raises ModuleNotFoundError: No module named 'pkg_resources'.
Written with AI assistance. Measured on 2026-10-24 on Linux with CPython 3.11.17 and setuptools 80.10.2, 81.0.0 and 84.2.1. Scripts and output pasted unedited except shortened paths. PlainTables is our extension; setuptools is free.