How to fix _decimal module compilation error when installing Python 3.3.2 in CentOS 5.9 (x86_64)?

I'm getting the following error when trying to compile Python 3.3.2 in CentOS 5.9 x86_64:

Failed to build these modules:
_decimal

I get this error when executing the "make" command (after the ./configure command).

Doing a Google search, I have found little information. It seems that the problem can be related to an old version of gcc, and can be solved upgrading the version of the linux distribution. But I must stick with CentOS 5.9, and I am already using the latest version of gcc available for CentOS 5.9 (gcc version 4.1.2).

Does anybody have been able to install Python 3.3.2 in CentOS 5.9?

Thank you for your help.


Solution 1:

Ok, I found a way.

You can install a newer version of gcc (4.4.7) along the default version that comes with CentOS 5.9, using only the official packages of CentOS 5.9 and without overwriting the installation of gcc 4.1.2.

Here are the steps:

1.- Using yum, install the following packages (may be you can get along with fewer packages, but I tried installing these 3):

yum install gcc44.x86_64
yum install gcc44-c++.x86_64
yum install libstdc++-devel.x86_64

2.- Set the CC environment variable to point to the gcc44 compiler:

export CC=/usr/bin/gcc44

3.- Run the commands as indicated in the README file of the Python 3.3.2 tarball:

./configure
make
make test
sudo make install

Now, after the first "make" you should not see the error message related to the "_decimal" module. And "make test" should complete successfully.

4.- Unset the CC environment variable:

unset CC

And that's it.

Solution 2:

Same problem here. Minor alteration on the solution that I used the

./configure --with-gcc=/usr/bin/gcc44

option. This is not explicitly mentioned in the help of the configure script, but it works.