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
multiprocessing module which has a similar interface to
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
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
$ tar zxvf Python-2.6.tgz
- Read the README at
- 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
$ cd Python-2.6 $ ./configure --prefix=/home/sofeng/lib/python2.6
$ makeNote 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 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 testI 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.
$ make install
- Finally, I added
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
- How to use pip with crate.io — posted 2012-10-24
- How to install MySQLdb in a virtualenv on Ubuntu Karmic — posted 2010-02-15
- How to install pip on Ubuntu — posted 2010-02-15
Using psycopg2 with virtualenv on Ubuntu
JauntyMaverick — posted 2009-07-31
- Notes on using pip and virtualenv with Django — posted 2009-05-06
13 Comments — Comments feed for this post
#1 -- commented on 2008-10-03:
For me (Hardy, too), additionally the following packages were missing:
libsqlite3-dev (for sqlite3) tk-dev (for tkinter)
I couldn't find packages for:
I recommend using 'checkinstall', because that way you can later easily replace the RC1 with the final:
$ sudo checkinstall
#2 Eliot commented on 2008-10-03:
--, Thanks for the tip. I probably installed sqlite and tkinter already, so I missed them. I will look into
#3 Sybren A. Stüvel commented on 2008-10-03:
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 2008-10-03:
Sybren, This sounds like a much easier way. Thanks a lot for the tip!
#5 Marek Kubica commented on 2008-10-17:
bsddb185 is an obsolete module and sunaudiodev is only available on Sun Solaris.
#7 Henry.Huang commented on 2008-12-06:
i got all down except:
How could get _dbm module?
#8 Eliot commented on 2008-12-08:
Henry, I did not get this error so I'm not sure, but I found a possible solution here: http://evalinux.wordpress.com/2008/12/04/installing-python-30-on-ubuntu-810-intrepid-ibex/#comment-493
#9 James Rubino commented on 2009-04-03:
How can I make Python 2.6 the "Grand Pumba" of python installs in my system?
#10 Jeff commented on 2009-04-16:
I second that question. To remove all previous installations, and only use 2.6, what do we do?
#11 Eliot commented on 2009-04-16:
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.