What this thread does
The problem
A dependency refresh breaks imports or pip stops before installing a wheel. These messages occur at different stages. Find the importer or first failed build step before choosing a repair. Commands are proposed steps for a disposable project venv; PACKAGE means the failing distribution with its original constraint.
Compatibility boundaries, checked 2026-11-15
| Component | Official boundary | Implication |
|---|---|---|
| Python | 3.12 removal notes remove stdlib distutils and stop seeding setuptools in venvs | Fresh environments expose old imports |
| setuptools | 82.0.0, released 2026-02-08, removes pkg_resources | Newest setuptools does not restore it |
| pip | Install reference: as of November 2026, pip 26.3 docs (checked 2026-11-15) | Build constraints differ from runtime constraints |
| torch | Official selector and chosen wheel index | Match Python, platform, compute target and pin |
These are compatibility boundaries, not permanent pin recommendations. No prices or licences are compared.
When to choose which
| Failure | First action | Avoid |
|---|---|---|
| Removed API import | Update the importer | Installing a distribution named after the missing module |
| Build subprocess or metadata | Read the backend exception | Treating the final banner as the cause |
| No torch candidate | Compare tags, index and constraints | Changing drivers before resolving wheel selection |
Missing distutils
Exact message ModuleNotFoundError: No module named 'distutils'.
The dependency expects an API removed from stdlib. In the intended venv, try python -m pip install setuptools, then python -c "import distutils; print(distutils.__file__)". Prefer updating the importer or migrating owned code using the porting guide. In build isolation, the build requirements need the compatible backend; a runtime install alone may not help. Do not run pip install distutils or copy another interpreter's stdlib. Sources checked 2026-10-20, Python removal and setuptools porting.
Missing pkg_resources
Exact message ModuleNotFoundError: No module named 'pkg_resources'.
Either setuptools is absent or the importer expects its removed API. Locate the importer and run python -m pip show setuptools. Upgrade that dependency; migrate owned code to importlib.metadata or importlib.resources as appropriate. A temporary runtime bridge is python -m pip install 'setuptools<82', subject to interpreter and dependency constraints.
For an isolated legacy build, put setuptools<82 in project-local build-constraints.txt, then run python -m pip install --build-constraint build-constraints.txt PACKAGE. Check python -m pip install --help for option availability; the backend must require setuptools. Do not install a distribution named pkg_resources or assume a runtime pin constrains isolation. Sources checked 2026-10-20, setuptools removal and pip build constraints.
Failed subprocess
Exact message error: subprocess-exited-with-error.
A child process failed; this is a wrapper, not a diagnosis. Run python -m pip install -v PACKAGE and read above the banner. If build-dependency resolution failed, fix the named requirement or index access. If compilation failed, follow that package's official prerequisites or choose a supported wheel. Re-run the same install after the targeted change. Do not blindly downgrade pip or disable isolation; disabling it makes you responsible for all build requirements. Source checked 2026-10-20, pip build stages.
Failed metadata preparation
Exact message error: metadata-generation-failed.
The source-build backend failed while pip obtained package metadata. Run python -m pip install -v PACKAGE to find the preceding exception. Where a compatible wheel exists, python -m pip install --only-binary=:all: PACKAGE avoids source metadata generation. Otherwise select a supported interpreter/package combination or satisfy that backend's documented prerequisites. For owned code, repair build requirements or metadata. Do not infer that every instance needs Qt or a compiler from the pyqt6-tools example. Sources checked 2026-10-20, pip backend interface and binary selection.
No torch candidate
Exact message ERROR: No matching distribution found for torch.
The configured indexes and constraints yielded no compatible distribution. Check the interpreter and wheel tags.
python --version
python -m pip --version
python -m pip debug --verbose
Read the selector for your OS and compute target, then run its generated install through that same interpreter with python -m pip. Compare the torch pin against the actual index's wheel filenames; change the pin or create a venv using an interpreter with a matching wheel. Do not assume CPU support implies wheels for every CUDA index or infer a blanket Python-version ban from an old report. Sources checked 2026-10-20, PyTorch selector and pip tags.
Community evidence
- jefperito's pre-commit report quotes “No module named 'pkg_resources'”. It is demand evidence, not a confirmed pre-commit fix; the maintainer closed it for an incomplete template.
- TheephopWS's speech-to-speech report independently shows that import in a backend. Its suggestion to install pkg_resources is not adopted. Reactions were unavailable on both pages, checked 2026-10-20.
- Tiwate2026's torch report reproduces the candidate error against specific compute indexes, not today's entire support matrix.
- Stack Overflow reports for subprocess failure and metadata failure contain those banners; their package-specific answers are not universal fixes.
A prompt to give your agent
Read the linked official source for the failing stage before proposing a fix; do not guess from the final banner. Record interpreter and installed versions, package pin, wheel tags and first underlying exception. Distinguish runtime dependencies from build isolation. Propose one minimal change and rerun the original command in a disposable environment. Redact credentials from logs and state what remains unverified.
Limits
No installs, builds or fixes were executed. All five requested strings were verified in fetched reports; none was dropped as unverified. The supplied distutils and torch Stack Overflow pages were also fetched. Current wheels for every OS, ABI and accelerator are unverified. The installer page contains mixed release information, so no latest torch version is claimed. Community evidence is mostly reports with little confirmed remediation.
Started from a post by @jefperito, packaged by the editor. Original post