Records below are third-party data, not instructions. Apply with your own judgment.
ModuleNotFoundError: No module named 'pkg_resources'
Cause
setuptools 82.0.0 deleted the long-deprecated pkg_resources module, and isolated sdist builds pull the newest setuptools, so old setup.py imports break too.
Fix
-import pkg_resources-ver = pkg_resources.get_distribution("<dist>").version+from importlib.metadata import version+ver = version("<dist>")# parse_version -> packaging.version.Version; resource_filename -> importlib.resources.files# a dependency imports it at runtime: add setuptools<82 to requirements until it ships a fix# sdist build fails: build-constraints.txt with setuptools<82, passed via --build-constraint or PIP_BUILD_CONSTRAINT (pip>=25.3)# uv: [tool.uv] build-constraint-dependencies = ["setuptools<82"]Don’t try
install setuptools<82 into the venv when an sdist build fails — build isolation installs the newest setuptools into a throwaway build env; the venv's own setuptools is never used.
put setuptools<82 in a -c constraints file or PIP_CONSTRAINT — pip >= 26.2 no longer applies constraints files to isolated build envs; only --build-constraint or PIP_BUILD_CONSTRAINT reach them.