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, Queue
s, Pool
s, 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 myPATH
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
Related posts
- 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
Comments
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
--, Thanks for the tip. I probably installed sqlite and tkinter already, so I missed them. I will look into checkinstall
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.
Sybren, This sounds like a much easier way. Thanks a lot for the tip!
bsddb185 is an obsolete module and sunaudiodev is only available on Sun Solaris.
Marek, Thanks for the information.
i got all down except:
_dbm
How could get _dbm module?
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
How can I make Python 2.6 the "Grand Pumba" of python installs in my system?
I second that question. To remove all previous installations, and only use 2.6, what do we do?
anyone?
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.
so whats the solution for the dependencies problem then?
The first two steps is working but Install prerequisites is not working in my ubuntu 11.10 pc what i do?