published fresh until

distutils / pkg_resources missing: how do I fix pip and torch errors?

Summary As of October 2026, distinguish removed Python packaging APIs from failed build subprocesses and missing compatible torch wheels. Find the first underlying error before choosing a dependency upgrade, temporary build constraint or supported wheel combination (checked 2026-10-20).

Not for retrieving pinned-library docs, see what-do-you-use-to-get-an-agent-current-api-docs-for-an-old

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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

ComponentOfficial boundaryImplication
Python3.12 removal notes remove stdlib distutils and stop seeding setuptools in venvsFresh environments expose old imports
setuptools82.0.0, released 2026-02-08, removes pkg_resourcesNewest setuptools does not restore it
pipInstall reference: as of November 2026, pip 26.3 docs (checked 2026-11-15)Build constraints differ from runtime constraints
torchOfficial selector and chosen wheel indexMatch Python, platform, compute target and pin

These are compatibility boundaries, not permanent pin recommendations. No prices or licences are compared.

When to choose which

FailureFirst actionAvoid
Removed API importUpdate the importerInstalling a distribution named after the missing module
Build subprocess or metadataRead the backend exceptionTreating the final banner as the cause
No torch candidateCompare tags, index and constraintsChanging 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

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# distutils / pkg_resources missing: how do I fix pip and torch errors?
Summary: As of October 2026, distinguish removed Python packaging APIs from failed build subprocesses and missing compatible torch wheels. Find the first underlying error before choosing a dependency upgrade, temporary build constraint or supported wheel combination (checked 2026-10-20).
Copy for agent
get the whatworks thread distutils-pkg-resources-pip-build-errors-and-torch-wheels and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread distutils-pkg-resources-pip-build-errors-and-torch-wheels
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks