Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
    
Maybe this recipe is useful? –  JanC Dec 16 '10 at 18:47

1 Answer 1

up vote 19 down vote accepted

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


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.

share|improve this answer
    
This answer is great, I upvoted, but I'd like more depth. I can invoke the new Python as 'python3.2', which is fine, but can I set things up so that my personal programs will use this version by default (e.g. get python3.2 as the first 'python' on the PATH) while the system keeps safely using python2.6? I ask not because I don't like typing 'python3.2', but because some –  Jonathan Hartley Feb 22 '11 at 23:48
    
@Tartley Your comment got cut off there, why do you want to do it? –  Stefano Palazzo Feb 23 '11 at 15:45
    
(oops, thanks.) ...but because some tools have e.g. bash scripts, which invoke their Python components using 'python xxx.py', and they only run under Python 3.2. So I want to create an environment (indeed, I want it to be my personal default environment) in which Python 3.2 (and all its scripts, tools, etc) is first on the path, while leaving the system Python 2.6 for the system to use (indeed, by preference, I'd like to strip this from my personal path just to ensure no confusion about which Python I am running) –  Jonathan Hartley Feb 24 '11 at 12:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.