SaltyCrane Blog — Notes on JavaScript and web development

Installing Python 2.6 from source on Ubuntu Hardy

Python 2.6 was released yesterday! This version aims to smooth the transition from Python 2.5 to Python 3.0 which is planned for release soon (currently available as a release candidate). Python 3.0 will be break backwards compatibility with the 2.x series. Python 2.6 is backwards compatible with 2.5. All the backwards compatible features of 3.0 have been backported to 2.6.

One of the new 2.6 features I'm particularly intersted in is the new multiprocessing module which has a similar interface to the threading module, but it uses processes instead of threads. This avoids the limitations imposed by the Global Interpreter Lock in a multi-threaded Python program. Yet it still has the nice communications and management features like Pipe()s, Queues, Pools, etc. I didn't plan to focus so much on the multiprocessing module in this post-- I just want to document my install notes on Ubuntu Linux. For all the new features in 2.6 see What's New in Python 2.6. (It is a long list).

  • Download the Python 2.6 compressed source tarball
    $ cd incoming
    $ wget http://www.python.org/ftp/python/2.6/Python-2.6.tgz
  • Unpack
    $ tar zxvf Python-2.6.tgz
  • Read the README at ~/incoming/Python-2.6/README

  • Install prerequisites (Disclaimer: I know nothing about libraries, packages, dependencies, etc. This is what I did-- I am not sure if I grabbed the correct prerequisites or not.)
    $ sudo apt-get install build-essential
    $ sudo apt-get install libncursesw5-dev
    $ sudo apt-get install libreadline5-dev
    $ sudo apt-get install libssl-dev
    $ sudo apt-get install libgdbm-dev
    $ sudo apt-get install libbz2-dev
    $ sudo apt-get install libc6-dev
    $ sudo apt-get install libsqlite3-dev
    $ sudo apt-get install tk-dev
  • Configure. I am installing to ~/lib/python2.6.
    $ cd Python-2.6
    $ ./configure --prefix=/home/sofeng/lib/python2.6
  • Make
    $ make
    Note I got the following message:
    Failed to find the necessary bits to build these modules:
    bsddb185           sunaudiodev   
    To find the necessary bits, look in setup.py in detect_modules() for the module's name.
    I was not able to find the Ubuntu packages for these.

  • Try it out (Optional)
    $ ./python
    Python 2.6 (r26:66714, Oct  2 2008, 15:32:46) 
    [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
  • Test (Optional)
    $ make test
    I got the following status:
    327 tests OK.
    33 tests skipped:
        test_aepack test_al test_applesingle test_bsddb185 test_bsddb3
        test_cd test_cl test_codecmaps_cn test_codecmaps_hk
        test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_curses
        test_gl test_imgfile test_kqueue test_linuxaudiodev test_macos
        test_macostools test_normalization test_ossaudiodev test_pep277
        test_py3kwarn test_scriptpackages test_socketserver test_startfile
        test_sunaudiodev test_timeout test_urllib2net test_urllibnet
        test_winreg test_winsound test_zipfile64
    Those skips are all expected on linux2.
  • Install
    $ make install
  • Finally, I added ~/lib/python/bin/python2.6 to my PATH

Notes

The first time I ran, I got this message:

Failed to find the necessary bits to build these modules:
_hashlib           _ssl               bsddb185
bz2                gdbm               readline
sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

I think I found Ubuntu packages for some of them:

  • _hashlib and _ssl in libssl-dev
  • bz2 in libbz2-dev
  • gdbm in libgdbm-dev
  • readline in libreadline5-dev

Comments


#1 -- commented on :

For me (Hardy, too), additionally the following packages were missing:

libsqlite3-dev (for _sqlite3) tk-dev (for _tkinter)

I couldn't find packages for:

_dbm

I recommend using 'checkinstall', because that way you can later easily replace the RC1 with the final:

$ sudo checkinstall


#2 Eliot commented on :

--, Thanks for the tip. I probably installed sqlite and tkinter already, so I missed them. I will look into checkinstall


#3 Sybren A. Stüvel commented on :

An easier way to get all the required dependencies, is to use apt-get to install the build dependencies for Python 2.5:

 apt-get build-dep python2.5

The only warnings I get then are:

Failed to find the necessary bits to build these modules:
bsddb185           sunaudiodev
To find the necessary bits, look in setup.py in
detect_modules() for the module's name.

#4 Eliot commented on :

Sybren, This sounds like a much easier way. Thanks a lot for the tip!


#5 Marek Kubica commented on :

bsddb185 is an obsolete module and sunaudiodev is only available on Sun Solaris.


#6 Eliot commented on :

Marek, Thanks for the information.


#7 Henry.Huang commented on :

i got all down except:

_dbm

How could get _dbm module?


#9 James Rubino commented on :

How can I make Python 2.6 the "Grand Pumba" of python installs in my system?


#10 Jeff commented on :

I second that question. To remove all previous installations, and only use 2.6, what do we do?

anyone?


#11 Eliot commented on :

James, Jeff,
If you wait another week (April 23), you can get Python 2.6 as the default python package in Ubuntu 9.04 Jaunty Jackalope. http://packages.ubuntu.com/jaunty/python/python If you can't wait, the Jaunty Release Candidate is available today.


#12 shahryar commented on :

so whats the solution for the dependencies problem then?


#13 vijesh commented on :

The first two steps is working but Install prerequisites is not working in my ubuntu 11.10 pc what i do?