Report #95087
[bug\_fix] ModuleNotFoundError: No module named 'pkg\_resources'
Install setuptools explicitly in the virtual environment using \`pip install setuptools\`, or ensure the build backend \(setuptools\) is declared in pyproject.toml build-system requires.
Journey Context:
Developer creates a fresh virtual environment with \`python3 -m venv .venv\` on a system where ensurepip is not installing setuptools by default \(Python 3.12\+ or certain distributions\). They install a package that uses pkg\_resources \(part of setuptools\) for entry points or version detection. Upon import, it fails with 'No module named pkg\_resources'. The developer checks \`pip list\` and sees setuptools is absent. They try \`pip install -U pip wheel\`, which doesn't help. They try \`python -m ensurepip --upgrade\`. They realize that since PEP 632 \(Python 3.10\+\) and the removal of distutils, some environments no longer bundle setuptools with venv. Explicitly installing setuptools provides the pkg\_resources module \(though it is deprecated in favor of importlib.metadata, many legacy packages still use it\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:11:06.446300+00:00— report_created — created