How to Solve Configure: Error: No Acceptable C Compiler Found in $PATH
When you install a package or application, there are several dependencies that such a package runs on. These dependencies power some (or all) parts of the package.
Often, some of these dependencies are bundled together or downloaded during installation. Other times, it is expected to be present within your system.
For Linux, a big example is when installing Python. The C compiler is an important dependency that it needs.
Well, that’s because Python is written in C. However, we might not have the C compiler present, and it is expected by the Python developers to be present on your Linux PC.
This article will show you how to solve the error message configure: error: no acceptable C compiler found in $PATH
when installing Python or any package that needs the C compiler.
Install gcc
to Solve configure: error: no acceptable C compiler found in $PATH
The GNU Compiler Collection (GCC) is a compiler that holds compilers for different programming languages from C and C++ to Go. In addition to these compilers, it holds important libraries run on the programming languages it supports.
From the description, we know it holds the C compiler that is not found in our $PATH
. Therefore, if you see this error message configure: error: no acceptable C compiler found in $PATH
, the gcc
compiler can help you solve it.
Let’s create the same error message scenario by installing Python on our Ubuntu PC. To install Python, we need to download the tgz
file, a compressed archive file using the GNU zip (gzip
) software holding the Python package.
To download the Python tgz
file, we can use the wget
command.
wget https://www.python.org/ftp/python/3.10.6/Python-3.10.6.tgz
The output of the command above is the below, and the Python-3.10.6.tgz
file is present within the working directory we executed in the above command.
Resolving www.python.org (www.python.org)... 151.101.16.223, 2a04:4e42:4::223
Connecting to www.python.org (www.python.org)|151.101.16.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25986768 (25M) [application/octet-stream]
Saving to: ‘Python-3.10.6.tgz'
Python-3.10.6.tgz 100%[=================================================>] 24.78M 6.16MB/s in 4.9s
2022-08-15 11:54:25 (5.10 MB/s) - ‘Python-3.10.6.tgz' saved [25986768/25986768]
You can use the ls
command to check for the file we downloaded. Afterward, we can extract the Python-3.10.6.tgz
file using the below command.
tar -zxvf Python-3.10.6.tgz
The code output is below and an extracted directory, Python-3.10.6
.
Python-3.10.6/
Python-3.10.6/Mac/
Python-3.10.6/Mac/README.rst
Python-3.10.6/Mac/Icons/
Python-3.10.6/Mac/Icons/PythonLauncher.icns
Python-3.10.6/Mac/Icons/IDLE.icns
Python-3.10.6/Mac/Icons/PythonCompiled.icns
Python-3.10.6/Mac/Icons/ReadMe.txt
...
Now, let’s cd
into the directory.
cd Python-3.10.6
Then, make a hidden directory using the command below.
mkdir ~/.localpython
Now, let’s configure the Python $PATH
to allow us to access Python anywhere.
./configure --prefix=/home/lazycruise/.localpython
Here is where the error message pops up.
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.10... no
checking for python3... python3
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "linux"
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/lazycruise/Python-3.10.6':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
You can see the second to the last line with the error message, configure: error: no acceptable C compiler found in $PATH
.
As we said earlier, the gcc
compiler holds the C compiler
we need to allow us to install Python successfully. So, let’s install the gcc
compiler using the command below.
sudo apt-get install build-essential
The above command installs a meta-package that doesn’t install anything but provides a link to several other packages installed as dependencies. For build-essential
, it installs everything required for compiling basic software written in C and C++.
These include the compiler we need, gcc
, g++
, libc6-dev
, make
, and dpkg-dev
. We can write and run C and C++ software on Ubuntu with all these packages.
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
binutils binutils-common binutils-x86-64-linux-gnu cpp cpp-9 dpkg-dev fakeroot g++ g++-9 gcc gcc-10-base gcc-9
gcc-9-base libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan5 libatomic1 libbinutils
libc-dev-bin libc6 libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0 libctf0 libdpkg-perl libfakeroot
libfile-fcntllock-perl libgcc-9-dev libgcc-s1 libgomp1 libisl22 libitm1 liblsan0 libmpc3 libquadmath0
libstdc++-9-dev libstdc++6 libtsan0 libubsan1 linux-libc-dev make manpages-dev
For other distributions or bases, the command will be different.
-
CentOS, Red Hat
sudo yum groupinstall "Development Tools"
-
openSUSE
zypper install --type pattern devel_basis
-
Alpine
apk add build-base
We can repeat our configure
command with the complete command execution.
./configure --prefix=/home/lazycruise/.localpython
Now, it is successful. Afterward, we execute the command below, which builds the Python program and files from the source code extracted into the current working directory.
make
Finally, we execute this command to install the Python program.
sudo make install
Therefore, to solve the configure: error: no acceptable C compiler found in $PATH
error message, all you need to do is install gcc
, which comes with the meta-package, build-essentials
on Ubuntu or similar distros.
Olorunfemi is a lover of technology and computers. In addition, I write technology and coding content for developers and hobbyists. When not working, I learn to design, among other things.
LinkedInRelated Article - Python Path
- The Path Python3 (From --Python=Python3) Does Not Exist
- How to Get Directory From Path in Python
- How to Set File Path in Python
- How to Change Python Path
- Relative Path in Python
Related Article - Python Error
- Can Only Concatenate List (Not Int) to List in Python
- How to Fix Value Error Need More Than One Value to Unpack in Python
- How to Fix ValueError Arrays Must All Be the Same Length in Python
- Invalid Syntax in Python
- How to Fix the TypeError: Object of Type 'Int64' Is Not JSON Serializable
- How to Fix the TypeError: 'float' Object Cannot Be Interpreted as an Integer in Python