No acceptable C compiler found in $PATH when installing python

PythonCompiler ErrorsVirtualenv

Python Problem Overview


I'm trying to install a new Python environment on my shared hosting. I follow the steps written in this post:

mkdir ~/src
wget http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgz
tar -zxvf Python-2.7.1.tar.gz
cd Python-2.7.1
mkdir ~/.localpython
./configure --prefix=/home/<user>/.localpython
make
make install

After coming to the ./configure --prefix=/home/<user>/.localpython command, I get the following output:

checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... linux3
checking EXTRAPLATDIR... 
checking machine type as reported by uname -m... x86_64
checking for --without-gcc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home3/mikos89/Python-2.7.1':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

How can this problem be solved? I've been trying to find a solution for 3 hours, but I'm still stuck in one place.

UPDATE

Hostgator does not allow gcc on their shared accounts:

Python Solutions


Solution 1 - Python

The gcc compiler is not in your $PATH. It means either you dont have gcc installed or it's not in your $PATH variable.

To install gcc use this: (run as root)

  • Redhat base:

     yum groupinstall "Development Tools"
    
  • Debian base:

     apt-get install build-essential
    
  • openSUSE base:

     zypper install --type pattern devel_basis
    

Solution 2 - Python

You need to run

yum install gcc

Solution 3 - Python

For Ubuntu / Debian :

sudo apt-get install build-essential

For RHEL/CentOS

sudo yum install gcc glibc glibc-common gd gd-devel -y

or

 sudo yum groupinstall "Development tools" -y

For more details, refer to this link.

Solution 4 - Python

Assuming you're on a debain/ubuntu system, you will need to run the following first:

sudo apt-get install build-essential

Solution 5 - Python

sudo apt install build-essential is the command.

However, if you get the "the package can be found" kind of error, run

  • sudo apt update first
  • then sudo apt install build-essential

This worked for me.

Solution 6 - Python

You would need to install it as non-root, since it's shared hosting. Here is a tutorial that goes through how to do this step.

cd ~/src
wget http://www.netgull.com/gcc/releases/gcc-5.2.0/gcc-5.2.0.tar.gz

or equivalent gcc source, then

tar -xvf gcc-5.2.0.tar.gz
cd gcc-5.2.0
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-5.2.0/configure --prefix=$HOME/gcc-5.2.0 --enable-languages=c,c++,fortran,go
make
make install

Then add to .bashrc, or equivalent:

export PATH=~/gcc-5.2.0/bin:$PATH
export LD_LIBRARY_PATH=~/gcc-5.2.0/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=~/gcc-5.2.0/lib64:$LD_LIBRARY_PATH

Solution 7 - Python

If you are using alphine with docker, do this:

apk --update add gcc make g++ zlib-dev

Solution 8 - Python

Issue:

> configure: error: no acceptable C compiler found in $PATH

I fixed the issue by executing the following command:

yum install gcc

to install gcc.

Solution 9 - Python

Get someone with access to the root account on that server to run sudo apt-get install build-essential. If you don't know who has root access, contact the support team for your shared hosting and ask them.

Edit: If you aren't allowed access to root, you aren't ever going to get it working. You'll have to change hosting provider I'm afraid.

Solution 10 - Python

Run apt-get install gcc in Suse Linux.

Solution 11 - Python

On Arch Linux run the following:

sudo pacman -S base-devel

Solution 12 - Python

For Ubuntu/Debian, run
sudo apt update

sudo apt install -y build-essential

Remember to add the flag -y to accept to continue by default.

Solution 13 - Python

You need just to install build-essential on Debian-family and Development tools on RedHat-family.

Solution 14 - Python

In a shared hosting, gcc compiler is disabled by default (in a terminal write gcc --version and it must return 'Permission denied' if installed...). It's very important to the next step.

Now, contact the support team and request to add your user id to 'compiler group'. This solves your problem and other - for example, you will be able to execute 'make' and 'make install' without problems, install the pillow library, etc.

Forget about 'sudo' or 'apk' commands. They are also disabled by default.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionmik.roView Question on Stackoverflow
Solution 1 - Pythonvahid abdiView Answer on Stackoverflow
Solution 2 - PythonmlowtonView Answer on Stackoverflow
Solution 3 - PythonLakshmikandanView Answer on Stackoverflow
Solution 4 - PythonTom SwiftyView Answer on Stackoverflow
Solution 5 - PythonMbigha SiggiView Answer on Stackoverflow
Solution 6 - PythonblambView Answer on Stackoverflow
Solution 7 - PythonSahith VibudhiView Answer on Stackoverflow
Solution 8 - PythonpassionatedevopsView Answer on Stackoverflow
Solution 9 - PythonwdhView Answer on Stackoverflow
Solution 10 - PythonBlackView Answer on Stackoverflow
Solution 11 - Pythonuser6735634View Answer on Stackoverflow
Solution 12 - PythonApexView Answer on Stackoverflow
Solution 13 - PythonArash ForoughiView Answer on Stackoverflow
Solution 14 - PythonDanView Answer on Stackoverflow