Installing Python 2.7.2 in Ubuntu 11.10 – UNRESOLVED?

The bottom line: I have a working python installation because I installed it LOCALLY, but when I attempt a global (or system-wide) installation (using sudo), I run into an error I can’t seem to crack.


My goal is to install Python 2.7.2 so I can integrate it with my parallel workflow. It’s not a very ambitious goal. I installed the Intel C compiler (no sweat), MPICH2, and now I’m at this necessary step before I install mpi4py, a wonderful tool developed here.


During my installation process, I covered two versions of Ubuntu (because I updated midstream). The two versions were the notoriously friendly 10.04, and now 11.10. These are home editions, not server editions. I’ve done a lot of experimental stuff regarding the graphics on my 10.04, so now a lot of stuff is broken, and I thought upgrading to 11.10 would fix a lot of the harm I caused (it did!). I’m using a 64 bit Intel architecture, Corei7.


I downloaded the Python-2.7.2.tgz package. I unpacked it somewhere friendly. Then I built somewhere else. I usually do this and it has worked out pretty well so far.


Here is a list of the commands that I issue. They should work and install Python, in theory.

Command 1
./configure –prefix=$INSTALL_DESTINATION CC=$INTEL_C_COMPILER 2>&1 | tee c.txt

Note that my $INSTALL_DESTINATION was only root accessible, meaning I needed to specify sudo when making any changes to that directory. I do the fancy tee because it is absolutely necessary to keep me from going mad. Printing a history of what I just did and when I did it is great bookkeeping. Keep in mind that I fiddled with my Intel compiler. I tried to use the 32 bit compilers but it wouldn’t configure. I wasn’t sure if that would help, and now I know it doesn’t.

Command 2
make 2>&1 | tee m.txt

Again, this is a simple command that will send its output to a text file. At this stage, I got some warnings. I did not format the warning for your reading enjoyment.

compilation aborted for /home/benjamin/Documents/installs/Python-2.7.2/Modules/_ctypes/libffi/src/x86/ffi64.c (code 2)

Python build finished, but the necessary bits to build these modules were not found:
_bsddb _sqlite3 _tkinter
bsddb185 bz2 dbm
dl gdbm imageop
readline sunaudiodev
To find the necessary bits, look in in detect_modules() for the module’s name.
Failed to build these modules:
_bisect _codecs_cn _codecs_hk
_codecs_iso2022 _codecs_jp _codecs_kr
_codecs_tw _collections _csv
_ctypes _ctypes_test _curses
_curses_panel _elementtree _functools
_hashlib _heapq _hotshot
_io _json _locale
_lsprof _multibytecodec _multiprocessing
_random _socket _ssl
_struct _testcapi array
audioop binascii cmath
cPickle crypt cStringIO
datetime fcntl future_builtins
grp itertools linuxaudiodev
math mmap nis
operator ossaudiodev parser
pyexpat resource select
spwd strop syslog
termios time unicodedata

At the very least, we presume that our make install may not go as expected. Considering that I was about to install in a root directory, I issued the command

Command 3
$ sudo make install 2>&1 | tee mi.txt

which gave me the error

Traceback (most recent call last):
  File "/opt/Python-2.7/lib/python2.7/", line 17, in <module>
    import struct
  File "/opt/Python-2.7/lib/python2.7/", line 1, in <module>
    from _struct import *
ImportError: No module named _struct
make: *** [libinstall] Error 1

From here, it’s been all suffering and confusion.


I came across a forum post that detailed the error very similar to mine (if not exactly similar, but probably not, because it wasn’t their solution that solved my problem). They recommended an upgrade of the make utility. Before their recent upgrade in 2010, make was last upgraded in 2006. Four years of waiting reduced my “Failure to build these modules” from above, to this:

Failed to build these modules:


My recommendation here is to update your installation of make. Yet, with all of these wonderful improvements, my installation still failed with the same error. To check your existing version of make, go into your terminal window and type

$make -v

To automatically download the 3.8.2 edition of make, click here.

So with make upgraded, I was still running into issues with _struct. I did attempt the solution found in the link I provided to the forum posting. It did not work. But I think it’s a good start. I did not find the system-wide python installation absolutely necessary, so installing it locally was a breeze. I may come back to this later to resolve, but I’ll take any comments below to try them out.

Note: If you keep attempting the installation from source, make sure you run

$ make clean

after every time your

$ make install

fails, before you run make again.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s