Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to build Python3 on a RHEL 5.7 machine, I successful managed to build Python 3.2.2, with :

# Install required build dependencies
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

# Fetch and extract source. Please refer to
# to ensure the latest source is used.
tar -xjf Python-3.2.tar.bz2
cd Python-3.2

# Configure the build with a prefix (install dir) of /opt/python3, compile, and install.
./configure --prefix=/opt/python3

But I am failing (?) with Python 3.2.3:

Failed to build these modules:

Is this a problem that should bother me ? How do I build it? I found this patch, but it's not included in sources Python 3.2.3 I obtained from the website ...

Here is the output from stderr:

 ~/tmp/Python-3.2.3 $ make > build.log
ldd: warning: you do not have execution permission for `/usr/local/lib/'
/usr/bin/ld: skipping incompatible /usr/local/lib/ when searching for -lreadline
/usr/bin/ld: skipping incompatible /usr/local/lib/libreadline.a when searching for -lreadline
/home/oznahum/tmp/Python-3.2.3/Modules/_posixsubprocess.c: In function '_close_open_fd_range_safe':
/home/oznahum/tmp/Python-3.2.3/Modules/_posixsubprocess.c:205: error: 'O_CLOEXEC' undeclared (first use in this function)
/home/oznahum/tmp/Python-3.2.3/Modules/_posixsubprocess.c:205: error: (Each undeclared identifier is reported only once
/home/oznahum/tmp/Python-3.2.3/Modules/_posixsubprocess.c:205: error: for each function it appears in.)
/usr/bin/ld: skipping incompatible /usr/local/lib/ when searching for -lz
/usr/bin/ld: skipping incompatible /usr/local/lib/ when searching for -lz

~/tmp/Python-3.2.3 $ grep posix build.log 
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes    -I. -IInclude -I./Include    -DPy_BUILD_CORE  -c ./Modules/posixmodule.c -o Modules/posixmodule.o
ar rc libpython3.2m.a Modules/_threadmodule.o  Modules/signalmodule.o  Modules/posixmodule.o  Modules/errnomodule.o  Modules/pwdmodule.o  Modules/_sre.o  Modules/_codecsmodule.o  Modules/_weakref.o  Modules/_functoolsmodule.o  Modules/operator.o  Modules/_collectionsmodule.o  Modules/itertoolsmodule.o  Modules/_localemodule.o  Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o  Modules/zipimport.o  Modules/symtablemodule.o  Modules/xxsubtype.o
building '_posixsubprocess' extension
gcc -pthread -fPIC -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -IInclude -I/home/oznahum/localroot/include -I. -I./Include -I/usr/local/include -I/home/oznahum/tmp/Python-3.2.3 -c /home/oznahum/tmp/Python-3.2.3/Modules/_posixsubprocess.c -o build/temp.linux-x86_64-3.2/home/oznahum/tmp/Python-3.2.3/Modules/_posixsubprocess.o
share|improve this question
Can you parse through your compile output and see if there's any mention of posixsubprocess or any lines containing error, just to verify that this is, indeed, the reason its failing? – Andrew M. May 14 '12 at 15:41
@AndrewM. sorry for the late reply, I added above the error output... – Oz123 May 15 '12 at 12:36
No worries; it does indeed look like this is the issue you're running into. I would consider filing a bug with the Python folks, as it looks like the patch had the right idea, but no longer covers all the cases. – Andrew M. May 15 '12 at 16:13
@AndrewM.sometimes working more than 8 hours a day is really counter productive ... you miss elementary things !!! The patch did help, i put a full report below. – Oz123 May 16 '12 at 12:45
up vote 4 down vote accepted

OK... I am answering here, not to leave the question unanswered. I re-downloaded the Python-3.2.3 sources and examined them. They indeed do not include that patch.
I re-applied the patch and tested the building on CentOS-5.7 and RedHat-5.7. I managed to compile with out errors.
So, I guess the key is to apply the patch correctly. My failed build had in Modules/_posixsubprocess:

199 static void
200 _close_open_fd_range_safe(int start_fd, int end_fd, PyObject* py_fds_to_keep)
201 {
202     int fd_dir_fd;
203     if (start_fd >= end_fd)
204         return;
205         fd_dir_fd = open(FD_DIR, O_RDONLY | O_CLOEXEC, 0);
206 #ifdef O_CLOEXEC
207      fd_dir_fd = open(FD_DIR, O_RDONLY | O_CLOEXEC, 0);
208 #else
209     fd_dir_fd = open(FD_DIR, O_RDONLY, 0);
210 #ifdef FD_CLOEXEC

Line 205, should have been deleted ...

share|improve this answer
Awesome! I'm glad this worked for you. I'm not quite sure why this patch wasn't in version 3.2.3, since the patch was submitted many months before, so hopefully it will appear in 3.2.4! :) – Andrew M. May 16 '12 at 15:25
This was issue reported and fixed - – Sridhar Ratnakumar Sep 5 '12 at 20:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.