Report #102859
[bug\_fix] ModuleNotFoundError: No module named 'setuptools' during \`pip install\` of a source distribution
Ensure setuptools is installed in the environment: \`pip install --upgrade pip setuptools wheel\`, or use a build frontend like \`pip install build\` and \`python -m build\`.
Journey Context:
A developer tried to install a package from a tarball \(source distribution\) with \`pip install mypackage.tar.gz\`. The build failed with ModuleNotFoundError for setuptools. They had recently created a new virtual environment and had not installed setuptools \(which is usually bundled with Python but was missing in some minimal environments like Docker\). They initially tried to install setuptools but got recursion because setuptools itself needed setuptools. The fix was to upgrade pip first \(\`pip install --upgrade pip\`\), which pulled the latest setuptools and wheel as dependencies. After that, the install succeeded. The root cause was that older versions of pip did not automatically install build dependencies; PEP 517/518 changed this. Now best practice is to always run \`python -m pip install --upgrade pip setuptools wheel\` in fresh environments.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T15:47:11.814863+00:00— report_created — created