In this tutorial, we will look at the cause of this error and provide possible solutions to resolve it.”
Cause of “Error Command “gcc” Failed With Exit Status 1”
This type of error occurs when you attempt to compile and install the python library that depends on a C compiler.
If Python cannot find GCC and other required build libraries, it will throw the “Error command “GCC” failed with exit status 1” error.
An example of this error is shown below:
From the example output above, we can see that the error is caused by Python.h header file. The python.h header file is part of the python development package.
Fix 1: Install GCC Compiler
One of the possible ways to fix the error is to ensure to install the latest GCC compiler is installed on your system.
You can do this by running the command:
Debian
REHL\Fedora\CentOS
Arch\Manjaro
macOS
Fix 2: Install Build Essentials & Build Dependencies
The next step you can take to fix this error is installing the build-essentials and build dependencies packages.
Build essentials refers to the packages used to compile packages, including GCC and G++ compilers.
We install these packages by running the command:
Debian
REHL\CentOS\Fedora
Arch\Manjaro
Fix 3: Install Python Dev Packages
The most common cause of this error is missing python development packages. Although they may come installed by default in some Linux distributions, you will need to install them manually.
You can install them by running them:
Debian
$ sudo apt-get install python3-dev
REHL\CentOS\Fedora
$ sudo dnf python3-devel
Arch\Manjaro
Conclusion
In this tutorial, you learned how to fix the “error command “GCC” failed with exit status 1” in three main steps.
Thanks for reading!!