[Solve]: subprocess-exited-with-error in Python

How to fix error: subprocess-exited-with-error in Python

When running the pip install order, you might experience an error that says:

With some analysis (googling, of course!) I encountered this error that usually occurs when pip fails to complete the installation procedure of a package.
The most typical causes for this error are:

  • A needed build tool is missing
  • The package doesn’t support the working system you’re using
  • The package doesn’t help the latest Python version
  • The package may need additional steps to install

The reason for this error is usually written in the log a few lines above or below it, so you are required to read the standard output carefully.

This tutorial will aid you in resolving what causes the error and how you can fix it in practice.

A needed build tool is missing

Sometimes, this error occurs because a required build tool is missing from the computer.

For instance, the installation of srsly on my Windows computer displays the following output:

If you’re getting the same error, then you need to install Microsoft Visual C++ Build Tools.

Once you installed the tool, run the pip install command again and see if it performs.
If that doesn’t function, setuptools, try upgrading pip, and wheels:

Once you upgrade these packages, try installing the package again.

2. The package doesn’t support the operating system you’re using

This error can occur when the package you’re testing to install doesn’t support the operating system you utilized.

For instance, text-to-speech TTS package doesn’t support macOS on Apple Silicon chips, so this error happens:

The mecab-python3 package is needed by TTS and it doesn’t support Apple M chips at the moment.
Fortunately, the package can be installed by operating brew:

Once mecab is seated, the TTS package can be installed successfully.

If you occur to have a similar error, you might be capable of finding a similar solution. Otherwise, there’s no method to fix this error except by utilizing another Operating System.

3. The package doesn’t support the latest Python version

Some packages that are no longer supported can cause this error when you try to install them on the latest version of Python.

You are required to search the error message and see if you have an identical output as follows:

In this case, there’s not much you can do but devaluate your Python version to the one supported by the package. Most probably, the library developers need more time to support the latest Python version.

Until then, you are required to use another Python version. Utilizing a virtual environment such as venv or conda should aid you in dealing with this problem.

4. The package requires additional steps to install

This error might happen because the package needs additional steps to complete the installation procedure.

For example, here’s the output when I tried to install pysqlite3:

After exploring for more information, I found that this package requires to be linked to an SQLite database to be installed.

If I don’t like to link the package manually, I can install the binary package, which is statically linked with the most current SQLite version.

This time, the package is installed without any errors. You need to google for more information if your particular package has the same exceptions.

Conclusion

The error: subprocess-exited-with-error happens when Python fails to run a subprocess successfully. Most likely, pip encountered an issue when running the setup.py script.
To fix this error, you need to make sure the required build tools are installed, the package supports the operating system you utilized, and the Python version you used is supported.

Avatar
Eram Naim, with 4 years of experience in content marketing and 2 years in digital marketing, currently serves as the Co-Founder and COO of Digitaltreed.com. In addition to his role as COO, he also functions as the Sales & Marketing Manager and Editor, showcasing his versatility and expertise across multiple domains within the company.