Solve Python error: subprocess-exited-with-error

avatar
Borislav Hadzhiev

Last updated: Apr 10, 2024
5 min

banner

# Solve Python error: subprocess-exited-with-error

To solve the error "subprocess-exited-with-error: This error originates from a subprocess, and is likely not a problem with pip":

  1. Upgrade your versions of pip, setuptools and wheel.
  2. Make sure you haven't got any missing dependencies.
  3. Make sure your Python version is supported by the package.
shell
note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for X ERROR: Could not build wheels for X, which is required to install pyproject.toml-based projects [end of output] error: subprocess-exited-with-error × pip subprocess to install build dependencies did not run successfully. │ exit code: 1 ╰─> See above for output.

# Upgrade your versions of pip, setuptools and wheel

The first thing you should try is to upgrade your versions of pip, setuptools and wheel.

shell
pip install wheel setuptools pip --upgrade pip3 install wheel setuptools pip --upgrade # 👇️ If you don't have pip in your PATH environment variable python -m pip install wheel setuptools pip --upgrade python3 -m pip install wheel setuptools pip --upgrade py -m pip install wheel setuptools pip --upgrade

update wheel setuptools pip

Try to run the pip install command after you have upgraded pip, setuptools and wheel.

# Try downgrading your version of pip to 21.3.1

If the error is not resolved, try to downgrade your version of pip to 21.3.1 before running pip install.

shell
pip install pip==21.3.1 pip3 install pip==21.3.1 python -m pip install pip==21.3.1 python3 -m pip install pip==21.3.1 py -m pip install pip==21.3.1

# Use the --use-deprecated-legacy option when installing the package

If that didn't help, try running the pip install command with the --use-deprecated-legacy option.

shell
pip install numpy --use-deprecated=legacy-resolver pip3 install numpy --use-deprecated=legacy-resolver python -m pip install numpy --use-deprecated=legacy-resolver python3 -m pip install numpy --use-deprecated=legacy-resolver py -m pip install numpy --use-deprecated=legacy-resolver # -------------------------------------------------------------- # 👇️ Set to backtrack-on-build-failures for older versions of pip pip install numpy --use-deprecated=backtrack-on-build-failures pip3 install numpy --use-deprecated=backtrack-on-build-failures python -m pip install numpy --use-deprecated=backtrack-on-build-failures python3 -m pip install numpy --use-deprecated=backtrack-on-build-failures

use the use deprecated legacy flag

Make sure to replace numpy with the name of the package you're trying to install.

The --use-deprecated option allows us to use the old resolver behavior when installing modules.

# Your error message might contain additional information

If the suggestions didn't help, read toward the end of your error message.

It might contain information such as: "RuntimeError: Cannot install on Python version 3.11.0; only versions >=3.7,<3.11 are supported."

In this case, you have to use a Python version that is supported by the package.

Your error message might also contain a missing package you have to install, e.g. ModuleNotFoundError: No module named 'X' or ImportError: cannot import name 'X'.

If that's the case, you have to pip install the package from the error message before installing the other package.

shell
pip install <package_from_error_message> pip3 install <package_from_error_message>

# Make sure you haven't misspelled the name of the package

Another common cause of the error is misspelling the name of the package and trying to install some broken, obsolete module by mistake.

# Installing Visual C++ build tools on Windows

If you are on Windows, make sure you have the Microsoft build tools installed.

Your error message might contain information such as "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/".

Download the Microsoft Build tools and check the "Desktop development with C++ checkbox when installing.

install microsoft build tools

# Check if your Python version is supported by the package

The error "note: This error originates from a subprocess, and is likely not a problem with pip" is sometimes caused when the package you are trying to install doesn't have available wheels for your version of Python.

You can check your Python version with the python --version command.

shell
python --version

get python version

You can check if a package has wheels available for a specific Python version in the Download files section of the package's pypi page.

For example, cp310 in the name of a file under "Built Distributions" means Python version 3.10 is supported for the specific operating system.

If the .whl files are not available for your version of Python, you can download an older version.

# Install the module with the --pre option

The first thing you should try though is to run the pip install command with the --pre option.

shell
pip install requests --pre pip3 install requests --pre python -m pip install requests --pre python3 -m pip install requests --pre py -m pip install requests --pre

install module with pre option

The --pre option makes it so pip includes pre-release and development versions of the package. By default pip only finds stable versions.

If that didn't work, you can download a specific Python version that is supported by the package if the package doesn't support the latest Python version.

Different versions are available in the "Looking for a specific release" table.

install specific python version

Make sure to tick the following options if you get prompted:

  • Install launcher for all users (recommended)
  • Add Python to PATH (this adds Python to your PATH environment variable)

If that didn't help and you don't already have a virtual environment, try creating one.

# Create a virtual environment

To solve the "note: This error originates from a subprocess, and is likely not a problem with pip" error:

  1. Create a virtual environment.
  2. Activate the virtual environment.
  3. Run the pip install command with the virtual environment active.
shell
# 👇️ Use the correct version of Python when creating VENV python3 -m venv venv # 👇️ Activate on Unix or MacOS source venv/bin/activate # 👇️ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # 👇️ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # 👇️ Upgrade pip pip install --upgrade pip # 👇️ Install the specific package in the virtual environment pip install requests

If the python3 -m venv venv command doesn't work, try one of the following commands:

  • python -m venv venv
  • py -m venv venv

Make sure to use the correct command to activate your virtual environment depending on your operating system and your shell.

Your virtual environment will use the version of Python that was used to create it.

# Install the package using a specific pip version

You might have multiple Python versions installed.

You can check your Python version with the python --version command.

shell
python --version python3 --version

get python version

For example, my Python version is 3.10.4, so I would install the package with pip3.10 install package-name.

shell
pip3.10 install package-name

install package using specific version of pip

Notice that the version number corresponds to the version of pip I'm using.

Make sure to replace package-name with the actual name of the package you're trying to install.

If you have issues with your pip installation, check out my other article on how to properly install and upgrade pip on all operating systems.

# Try running pip install in verbose mode

If none of the suggestions helped, try running the pip install command in verbose mode.

shell
pip install requests -vvv pip3 install requests -vvv python -m pip install requests -vvv

install package in verbose mode

The -v option stands for verbose mode and can be used up to 3 times.

When the pip install command is run in verbose mode, the command shows more output and how the error occurred.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.