When running the pip install order, you might experience an error that says:
error: subprocess-exited-with-error
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.
Read Also: How to Compare String in Python? [With Examples]
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:
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
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:
# upgrade pip
pip install --upgrade pip
# or if you have pip3
pip3 install --upgrade pip
# if you don't have pip in PATH
python -m pip install --upgrade pip
python3 -m pip install --upgrade pip
# for Windows
py -m pip install --upgrade pip
# upgrade setuptools and wheel
pip install --upgrade setuptools wheel
pip3 install --upgrade setuptools wheel
python -m pip install --upgrade setuptools wheel
python3 -m pip install --upgrade setuptools wheel
py -m pip install --upgrade setuptools wheel
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:
error: subprocess-exited-with-error
× Running setup.py install for mecab-python3 did not run successfully.
│ exit code: 1
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:
brew install mecab
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.
Read Also: How to Choose the Right Python Development Company?
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:
RuntimeError: Cannot install on Python version 3.11.2;
only versions >=3.7,<3.11 are supported.
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:
pip3 install pysqlite3
...
Failed to build pysqlite3
Installing collected packages: pysqlite3
Running setup.py install for pysqlite3 ... error
error: subprocess-exited-with-error
× Running setup.py install for pysqlite3 did not run successfully.
After exploring for more information, I found that this package requires to be linked to an SQLite database to be installed.
Read Also: Top 10 Programming Languages to Learn in 2023
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.
pip install pysqlite3-binary
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.
Leave a Reply