Report #97161
[bug\_fix] ModuleNotFoundError: No module named 'pkg\_resources' after installing or upgrading packages
Install setuptools in the active environment: \`python -m pip install -U setuptools\`. If your own code imports \`pkg\_resources\`, migrate it to \`importlib.resources\` \(files/data\) and \`importlib.metadata\` \(entry points/distributions\) from the standard library, because \`pkg\_resources\` is deprecated and may be removed from setuptools in the future.
Journey Context:
After a fresh install or a setuptools upgrade, a script or CLI tool fails at startup with \`ModuleNotFoundError: No module named 'pkg\_resources'\`. You check \`pip list\` and see the package that throws the error is installed. The environment simply does not have \`setuptools\` installed, or has a version \(70\+\) that no longer vendors \`pkg\_resources\`. Installing setuptools restores the module, but the durable fix is to remove the \`pkg\_resources\` import from your code and use \`importlib.metadata\`/\`importlib.resources\`, which are part of the standard library and do not depend on setuptools at all.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T04:38:41.133591+00:00— report_created — created