views:

13276

answers:

4

Hi,

I'd like to how to upgrade the default python installation(2.5.2) supplied with ubuntu 8.04 to python 2.6rc2. I'd like to make 2.6 the default python version on the system and migrate all the other useful installed python libraries installed on 2.5.2 to python 2.6rc2. Please let me know how I can achieve this.

Thanks Dirk

+9  A: 

With the warning that I think it's a tremendously bad idea to replace the default Python with an unreleased beta version:

First, install 2.6rc2. You can download the source from the Python website. Standard ./configure && make && sudo make install installation style.

Next, remove the /usr/bin/python symlink. Do not remove /usr/bin/python2.5. Add a symlink to 2.6 with ln -s /usr/local/bin/python2.6 /usr/bin/python.

Once again, I think this is a terrible idea. There is almost certainly a better way to do whatever you're trying to accomplish.


Migrating installed libraries is a much longer process. Look in the /usr/lib/python2.5/site-packages/ and /usr/local/lib/python2.5/site-packages/ directories. Any libraries installed to them will need to be re-installed with 2.6. Since you're not using a packaged Python version, you cannot use Ubuntu's packages -- you'll have to manually upgrade all the libraries yourself. Most of them can probably be installed with sudo easy_install <name>, but some like PyGTK+ are not so easy. You'll have to follow custom installation procedures for each such library.

John Millikin
will the default compilation options not just add it to /usr/local/bin (which he could then rename to python26), while leaving the /usr/bin symlink pointing to python2.5?
bvmou
It's common for shell scripts to use #!/usr/bin/python, rather than #!/usr/bin/env python. Because if this, the link in /usr/bin must be replaced.
John Millikin
Actually, the correct way (if you're targeting a specific version) is #!/usr/bin/env python2.6
Jeremy Cantrell
Jeremy: I read the original question as saying he wanted to change the global default for scripts to use Python 2.6.
John Millikin
+1  A: 

Is there any need to?

Ubuntu in general doesn't package RC releases. 2.6 will not be available in Ubuntu until Jaunty Jackalope.

However,, if you insist that you need to install it, then, you'll have to do so without a package manager.

Download the package, and unzip it to a directory

run the following commands (waiting for each to finish as you do so)

./configure
make
sudo make install

There, you have it installed.

It's better to wait for it to be packaged first, espescially as Python is used in a lot of ubuntu internals, so may break your system horribly

Mez
+1  A: 

It would not be wise to change the default version of Python, i.e. what you get when you type "python" into a shell. However, you can have multiple versions of python installed. The trick is to make sure that the program named "python" on the path is the system supplied version. If you want to run your install of Python 2.6 you'd then type python2.6 into a shell to start it.

Download the package and unzip it, then run:

./configure
make
sudo make install
ls -l /usr/local/bin

You should see a python and a python2.6 file, both created on the day you ran make install; delete the python file. Then when python is launched the standard system Python version from /usr/bin will be run, and when python2.6 is run you get your shiny new python 2.6rc2. Python displays the version when it starts an interactive interpreter.

Dickon Reed
+6  A: 

I have the same issue, and apparently pre-built binaries can be found here:

# Python 2.6
deb http://ppa.launchpad.net/doko/ubuntu intrepid main
deb-src http://ppa.launchpad.net/doko/ubuntu intrepid main
Staale