Upgrading to python 3.2

I want to use new functools that provides with the lrucache, I am currently using python 2.6, which doesn't support this,

What is the best way I can upgrade to python 3.2? or is there any other way that I can use the itertools+functools of 3.2 release in python 2.6 distribution

Thank you


Since many programs and libraries rely on Python 2.6 (or python 2.7 in 11.04), and since python 2.x and 3.x are incompatible, you can't upgrade - you can only install python3 alongside python 2.6:

Python 3.1

  • Luckily, the stable release of Python 3 (3.1.2 at the time of writing this) is provided in the repositories. Just install the python3-all  package.

    Your interpreter will be /usr/bin/python3 instead of /usr/bin/python.

    You can also now type python3 in your terminal when you want to launch Py3 instead of Py2.


Python 3.2

  • You can, download any version of the python sources from python.org and run

    ./configure
    make
    sudo make altinstall
    

    To be able to compile the python source, you'll need a few packages:

    sudo apt-get install build-essential libncursesw5-dev libreadline5-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev tk-dev libbz2-dev
    

    The altinstall option will install the other version of python alongside your existing ones:

    It makes sense to, instead of downloading the sources, check out the latest development release from the python dev repository every so often:

    svn checkout http://svn.python.org/projects/python/branches/py3k
    

    This will give you the very latest development, unstable, version. you can then cd py3k/ and do the above compilation procedure.

    For this, svn  needs to be installed of course.