Skip to main content

How to Resolve "error: subprocess-exited-with-error" in Python pip

When installing a Python package, the error: subprocess-exited-with-error is a generic message from pip that indicates a critical failure during the package's installation script (setup.py). This is not the real error, but rather a final summary that a command running in the background has failed.

The key to solving this issue is to understand that the actual reason for the failure is always printed in the lines of text above this summary message. This guide will teach you how to read the pip logs to find the root cause and will cover the most common problems and their solutions.

How to Diagnose the Real Error

The subprocess-exited-with-error message simply tells you that something went wrong. To find out what, you must scroll up in your terminal output and look for the specific error that stopped the installation. It is usually just above a long line of dashes (----) or the text [end of output].

Learning to find and interpret this initial error message is the most important step. The following sections cover the most common messages you will find.

Common Cause 1: Missing C/C++ Compiler or Build Tools

Many Python packages use C or C++ extensions for performance. To install them, pip needs to compile this code, which requires a compiler on your system.

Example of Error Log Clue (in Windows):

... (build output) ...
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

The log explicitly tells you that "Microsoft Visual C++ 14.0 or greater is required."

Solution: install the appropriate build toolchain for your operating system.

  • Windows: Download and install "Build Tools for Visual Studio" from the link provided in the error message. Ensure you select the "C++ build tools" workload during installation.
  • Debian/Ubuntu: sudo apt install build-essential python3-dev
  • Fedora/RHEL/CentOS: sudo dnf groupinstall "Development Tools"
  • macOS: Install the Xcode Command Line Tools with xcode-select --install.

Common Cause 2: Missing Non-Python System Dependencies

Some Python packages are "wrappers" around external libraries and require those libraries' development headers to be installed on your system.

Example of Error Log Clue (in macOS): when installing the TTS (Text-to-Speech) package, you might see a failure related to one of its dependencies:

... (build output) ...
× Running setup.py install for mecab-python3 did not run successfully.
│ exit code: 1
... (more details) ...
error: subprocess-exited-with-error

The log indicates the failure happened while installing mecab-python3. A quick search reveals that this requires the mecab library to be installed at the system level.

Solution: install the missing system library using your OS's package manager.

  • For mecab on macOS: brew install mecab
  • For libxml2 on Debian/Ubuntu: sudo apt-get install libxml2-dev
  • For openssl on Fedora: sudo dnf install openssl-devel

You must read the logs to identify which specific library is missing.

Common Cause 3: Incompatibility with Python Version or OS

The package you are trying to install may not support your current Python version or operating system/architecture (e.g., Apple Silicon).

Example of Error Log Clue: the log is often very direct about this:

... (build output) ...
RuntimeError: Cannot install on Python version 3.11.2;
only versions >=3.7,<3.11 are supported.
...
error: subprocess-exited-with-error

Solution:

  1. Check the package's PyPI page for its supported Python versions.
  2. If your version is not supported, you must use a different, compatible Python version. Tools like pyenv or conda are excellent for managing multiple Python versions on a single machine.
  3. If it's an OS/architecture issue (e.g., Apple Silicon), search for specific installation instructions, as there may be an alternative package (e.g., tensorflow-macos instead of tensorflow).

Common Cause 4: Outdated Packaging Tools

Older versions of pip, setuptools, or wheel may not understand modern packaging formats, leading to build failures. This is a simple and common issue.

Solution: before trying more complex solutions, always try upgrading your packaging tools.

python3 -m pip install --upgrade pip setuptools wheel

After upgrading, attempt the installation again. This simple step resolves a surprising number of build errors.

Conclusion

The error: subprocess-exited-with-error is a generic failure notification, not the root cause. To fix it, you must become a detective and analyze the full error log.

Underlying ProblemClue in the LogSolution
Missing CompilerMicrosoft Visual C++ ... is required, command 'gcc' failedInstall the C++ build tools for your OS.
Missing System Libraryerror: ... executable not found, Could not find ...Install the required development library using apt, dnf, brew, etc.
IncompatibilityRuntimeError: Cannot install on Python version XUse a different, supported version of Python.
Outdated Tools(Often no clear clue, a good first step)Upgrade your packaging tools: pip install --upgrade pip setuptools wheel.

By carefully reading the logs, you can identify the specific system requirement or incompatibility and take the correct action to resolve the installation failure.