Linux

How to Resolve Configure: Error: no acceptable C compiler found in $PATH

Python Installation

Tried to install python 3.7.1 and met this error: configure: error: no acceptable C compiler found in $PATH

First of all, I downloaded the source from python official site, and then extract it.

[root@test python]# curl -O https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 21.7M  100 21.7M    0     0   850k      0  0:00:26  0:00:26 --:--:--  959k
[root@test python]# tar -zxf Python-3.7.1.tgz
[root@test python]# cd *
[root@test Python-3.7.1]# mkdir mypython

Now we start to configure it to a predefined destination.

[root@test Python-3.7.1]# ./configure --prefix=$HOME/python/mypython
...
checking MACHDEP... checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/python/Python-3.7.1':
configure: error: no acceptable C compiler found in $PATH

See `config.log' for more details

no acceptable C compiler found in $PATH

This configuration error seemed to be related to missing or found no acceptable C compilers in $PATH. Since we are using a minimal version of Linux, it doesn’t have gcc (GNU Compiler Collection) package installed, which is a proper and suitable C compiler for make.

And what is $PATH? PATH is an environment variable on Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting.

So next, I install the proper C compiler gcc by the following command and then it will appear in $PATH afterwards:

[root@test ~]# yum -y install gcc
...

In fact, there’s a better way to pass all dependency issue like no acceptable C compiler found in $PATH during whole installation. That is to say, you may need all essential development tools including all kinds of supportive and acceptable compilers.

[root@test ~]# yum -y groupinstall "Development Tools"
...

Now we can try it again and finish the rest of the installation.

[root@test Python-3.7.1]# ./configure --prefix=$HOME/python/mypython
...
[root@test Python-3.7.1]# make
...
[root@test Python-3.7.1]# make test
...
[root@test Python-3.7.1]# make install
...
ModuleNotFoundError: No module named '_ctypes'
make: *** [install] Error 1

libffi-devel is Required

Even if the configuration is done well and C compiler is now acceptable, we found another issue about C compiler interface occurred during make install. In addition to C compiler, we need libffi-devel package to solve the problem.

[root@test Python-3.7.1]# yum -y install libffi-devel
...

Let’s do it again. This time, make install found an acceptable C compiler in $PATH and worked well.

[root@test Python-3.7.1]# make install
...
Looking in links: /tmp/tmp8b7ksh64
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1

I don’t see Configure: Error: no acceptable C compiler found in $PATH. Do you?

GeoIP Installation via PECL

Same error no acceptable C compiler found in $PATH occurred when installing geoip via PECL utility.

[root@test ~]# pecl install geoip-1.1.1
...
checking for cc... no
checking for gcc... no
configure: error: in `/var/tmp/pear-build-rootS2pmRo/geoip-1.1.1':
configure: error: no acceptable C compiler found in $PATH

See `config.log' for more details
ERROR: `/var/tmp/geoip/configure --with-php-config=/usr/bin/php-config' failed

no acceptable C compiler found in $PATH

Same error occurred again. So I installed development tools, a package group just like the above solution in python installation.

[root@test ~]# yum -y groupinstall "Development Tools"
...

Let’s try again.

[root@test ~]# pecl install geoip-1.1.1
downloading geoip-1.1.1.tgz ...
Starting to download geoip-1.1.1.tgz (13,004 bytes)
...
checking for geoip files in default path... not found
configure: error: Please reinstall the geoip distribution
ERROR: `/var/tmp/geoip/configure --with-php-config=/usr/bin/php-config' failed

It still failed, but it’s not about no acceptable C compiler found in $PATH. It’s about geoip-1.1.1.

geoip-1.1.1 is Required

No such Configure: Error: no acceptable C compiler found in $PATH this time. But we have another error which told us to install a proper package called geoip-devel first.

[root@test ~]# yum -y install geoip-devel
...

Then I tried to make it right again.

[root@test ~]# pecl install geoip-1.1.1
downloading geoip-1.1.1.tgz ...
Starting to download geoip-1.1.1.tgz (13,004 bytes)
...
Build process completed successfully
Installing '/usr/lib64/php/modules/geoip.so'
install ok: channel://pecl.php.net/geoip-1.1.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=geoip.so" to php.ini

This time, we’re good.

In conclusion, the lesson I learned from this error no acceptable C compiler found in $PATH is that we should know and install all dependencies of configuration packages before installing python and geoip. In this case, we need an acceptable C compiler found in $PATH in order to make install all kinds of sources.

Leave a Reply

Your email address will not be published. Required fields are marked *