Report #70086
[bug\_fix] ImportError: No module named 'pkg\_resources' in fresh Python 3.12 venv
Explicitly install \`setuptools\` into the virtual environment using \`pip install setuptools\`, or migrate code to use \`importlib.metadata\` \(stdlib\) instead of \`pkg\_resources\` for entry point discovery and version queries, as \`pkg\_resources\` is deprecated.
Journey Context:
Developer creates a fresh virtual environment using \`python3.12 -m venv myenv\` and activates it. They run \`pip install -e .\` on a legacy project that uses \`setup.py\`. The install seems to work. They then run a script that executes \`import pkg\_resources\` \(common in legacy entry point discovery or version checking\). It fails with \`ModuleNotFoundError: No module named 'pkg\_resources'\`. Developer is confused because \`pip\` worked, and \`pkg\_resources\` used to be automatically available in older Python/venv versions. They check \`pip list\` and see \`setuptools\` is missing. Realizing that Python 3.12\+ venvs no longer include \`setuptools\` by default \(only \`pip\`\), they understand that \`pkg\_resources\` is part of \`setuptools\`, not the stdlib. Installing \`setuptools\` restores \`pkg\_resources\`, though migrating to \`importlib.metadata\` is the long-term fix.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:13:08.641784+00:00— report_created — created