The “error command gcc failed with exit status 1” error is a very common error that is mainly related to the GCC compilation and required libraries. This error text is longer than this. The remaining part expresses the specific application name or libraries. In this tutorial, we examine how to find the error cause and solve it by installing required libraries or packages. Also, we provide some common solutions which can solve the problem in most cases.
“error command gcc failed with exit status 1” Error
As stated previously the error is mainly related when we try to install 3rd party library generally related with Python the compilation process starts. The gcc is used for compilation and the compilation process requires some development libraries. If these development libraries are not installed or not found the gcc returns error. Error looks like below.
Running greenlet-0.3.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_httHYm/greuulet-0.3.4/egg-dist-tmp-t9_gbW In file included from greenlet.c:5:0: greenlet.h:9:20: fatal error: Python.h: No such file or directory compilation terminated. error: Setup script exited with error: command 'gcc' failed with exit status 1`
The error cause is located in the 4th line. The “fatal error: Python.h: No such file or directory” expression explain what is the cause. It simply says that the Python development library or packages are not install or found.
Install Up-to-Date GCC
The GCC is used to compile given source code. If he GCC is not uptodate or even not installed the compilation ends with error. So first step is updating or installing the GCC.
Ubuntu, Debian, Mint, Kali:
sudo apt update gcc
CentOS, RHEL, Fedora:
sudo dnf update gcc
MacOSX:
brew install gcc
Install Build Essentials
The build essentials are libraries and packages used to build source code. They are essential to build most of the packages. By installing this package the error can be solved.
Ubuntu, Debian, Mint, Kali:
sudo apt install build-essential
CentOS, RHEL, Fedora:
sudo dnf install build-essential
Install Python Development Packages
The most prolific reason for the “error command gcc failed with exit status 1” is the absence of the Python development library or package. The Python development library or package is named “python-devel” or “python-dev” in most of the distributions. According to your python version select the proper python development library installation command from below.
Ubuntu, Debian, Mint, Kali:
sudo apt install python-dev
sudo apt install python3-dev
CentOS, RHEL, Fedora:
sudo dnf install python-devel
sudo dnf install python3-devel
Install libffi, libxslt and openssl Development Packages
Other popular libraries are libffi, libxslt and openssl. They generally required by Python tools and libraries for compilation. So you can install these libraries with the following commands.
Ubuntu, Debian, Mint, Kali:
sudo apt install libxslt-dev libffi-dev libssl-dev
CentOS, RHEL, Fedora:
sudo dnf install libxslt-devel libffi-devel openssl-devel