7

I am using Ubuntu 10.10 which comes by default installed with Python 2.6, however some applications that I want to use require 2.7 and I want to update.

How would I go about doing this?

Alex
  • 71

3 Answers3

5

It is already in the official repositories: http://packages.ubuntu.com/maverick/python2.7

sudo apt-get install python2.7

You then execute python2.7

P.S. Support for ubuntu 10.10 ends in April 2012: https://wiki.ubuntu.com/Releases

  • When I do this, the command python still uses 2.6, and using python2.7 would cause problems for me when installing modules. Is there a way to replace it over 2.6? – Alex Feb 10 '12 at 00:57
  • May I ask what kind of problems? :) You can link python to use python2.7, but I wouldn't suggest that, /usr/bin/python is used by most python packages in ubuntu and might cause problems if you attempt to change it. If you want to use python 2.7 for your program, use on top of the myfile.py #!/usr/bin/python2.7 and chmod +x myfile.py. Then run it as ./myfile.py – Savvas Radevic Feb 10 '12 at 01:07
  • 1
    ..or just upgrade your ubuntu. 11.04 has 2.7 as default: http://packages.ubuntu.com/natty/python – Savvas Radevic Feb 10 '12 at 01:09
  • The problem is that whenever I install a Python module, say for example python-twitter, it installs it but for the 2.6/default installation, so I would be unable to use it while using python2.7 – Alex Feb 10 '12 at 01:10
  • 1
    There is also a python-twitter package :) But you can always link the .py library files/folders in the according 2.7 directory, I think it's /usr/lib/python2.7/dist-packages/ – Savvas Radevic Feb 10 '12 at 01:16
  • I tried copying those files, but still doesn't recognize the module when called. – Alex Feb 10 '12 at 01:29
  • 1
    Hm.. maybe you forget using python2.7 setup.py? Also, if the package uses setup.py for installation, you can change the directory: sudo python2.7 setup.py install --libdir=/usr/lib/python2.7/dist-packages/ (or something like that, use --help if it doesn't work) – Savvas Radevic Feb 10 '12 at 01:30
  • I don't use any setup for the modules I used, I just install them with apt-get – Alex Feb 10 '12 at 01:33
  • I'm going to suggest, as medigeek has, that you upgrade your Ubuntu version after backing up critical data. Ubuntu 11.04 uses Python 2.7 by default, and it would remove a ton of issues you are having out of the equation. – Thomas Ward Feb 10 '12 at 08:32
3

The Deadsnakes PPA is helpful for old and new versions of Python.

Lucid through Precise is supported with versions 2.x and 3.x available. Since you are looking for 10.10, the direct link is:

https://launchpad.net/~fkrull/+archive/deadsnakes?field.series_filter=maverick

Octavian Helm
  • 14,355
Teg
  • 131
1
  1. Update Ubuntu 10.10 sources (credit).

    Because 10.10 is no longer supported.

    sudo sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
    sudo apt-get update
    
  2. Install add-apt-repository command (credit):

    This stops you from getting the sudo: add-apt-repository: command not found error in the next step.

    sudo apt-get install python-software-properties
    
  3. Install Deadsnakes PPA (credit):

    sudo add-apt-repository ppa:fkrull/deadsnakes
    sudo apt-get update
    
  4. Install Python 2.7:

    sudo apt-get install python2.7
    
  5. Profit!

    $ python2.7 --version
    Python 2.7.4
    


Edit: You can also install python 3.3 this way. Just replace step 4 with:
sudo apt-get install python3.3

Same goes for python 2.4, 2.5, 3.1, 3.2, etc.

meshy
  • 125
  • 8