Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Development & Programming > Programming Talk
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Ubuntu 9.10 is out!!!

When downloading Ubuntu 9.10 please consider using bittorrent to get your copy of Ubuntu.

The Ubuntu Developers Summit for Lucid Lynx will be held the week of 16-Nov-2009 till 20-Nov-2009 in Dallas, TX USA. Visit the the Ubuntu wiki for more information about UDS and how to participate remotely.

Programming Talk
This forum is for all programming questions.
The questions do not have to be directly related to Ubuntu and any programming language is allowed.

 
Thread Tools Display Modes
Old December 9th, 2006   #1
cyberslayer
5 Cups of Ubuntu
 
Join Date: Nov 2006
Beans: 41
Ubuntu 9.04 Jaunty Jackalope
Setting Python2.5 to Run From The Command Line

I have installed the python2.5 package on my system and I would like to know how to configure my system so that it will run the python2.5 interpreter when I type 'python' on the command line. Currently it seems to be set to run Python2.4 instead when I type 'python'. I noticed that there are python2.4 and python2.5 executables in /usr/bin and there is also a file named python which is a link to an executable. When I look under properties I can see that it is linked to python2.4 so I can see why typing python from the command line runs python2.4 and not python2.5 but I don't know how to change this. Could someone please tell me how to change the target of the python file?

Thanks
cyberslayer is offline   Reply With Quote
Old December 9th, 2006   #2
jan247
Just Give Me the Beans!
 
Join Date: Nov 2005
Beans: 51
Ubuntu 6.10 Edgy
Re: Setting Python2.5 to Run From The Command Line

Code:
sudo rm /usr/bin/python
sudo ln -s /usr/bin/python2.5 /usr/bin/python
jan247 is offline   Reply With Quote
Old December 9th, 2006   #3
asimon
Ubuntu Extra Shot
 
asimon's Avatar
 
Join Date: Oct 2004
Location: Germany, Old Europe
Beans: 379
Kubuntu Jaunty Jackalope (testing)
Re: Setting Python2.5 to Run From The Command Line

Quote:
Originally Posted by jan247 View Post
Code:
sudo rm /usr/bin/python
sudo ln -s /usr/bin/python2.5 /usr/bin/python
The debian way to do this is
Code:
$ sudo update-alternatives --config python
asimon is offline   Reply With Quote
Old December 9th, 2006   #4
cyberslayer
5 Cups of Ubuntu
 
Join Date: Nov 2006
Beans: 41
Ubuntu 9.04 Jaunty Jackalope
Re: Setting Python2.5 to Run From The Command Line

Ok. Thanks for your help. It works now.
cyberslayer is offline   Reply With Quote
Old December 9th, 2006   #5
kperkins
Way Too Much Ubuntu
 
kperkins's Avatar
 
Join Date: Feb 2005
Location: Maine, USA
Beans: 290
Re: Setting Python2.5 to Run From The Command Line

Quote:
Originally Posted by asimon View Post
The debian way to do this is
Code:
$ sudo update-alternatives --config python
Except when I try this, it says there are no alternatives for python--which I know is false, since I have 2.4 and 2.5 on my system.
kperkins is offline   Reply With Quote
Old December 9th, 2006   #6
Wybiral
Tall Cafè Ubuntu
 
Wybiral's Avatar
 
Join Date: Oct 2006
Beans: 2,678
Ubuntu 7.10 Gutsy Gibbon
Re: Setting Python2.5 to Run From The Command Line

Same here, I have 2.4 and 2.5 and it told me there were no alternatives either. I don't really mind as I rarely use python in the terminal, just thought I would point that out.
Wybiral is offline   Reply With Quote
Old December 10th, 2006   #7
po0f
Chocolate-Covered Ubuntu Beans
 
Join Date: Sep 2006
My beans are hidden!
Re: Setting Python2.5 to Run From The Command Line

cyberslayer,

If you want to set it up for just one user, you can set an alias for it in ~/.bashrc:
Code:
alias python='/usr/bin/python2.5'
I really don't suggest changing /usr/bin/python to point to /usr/bin/python2.5, because I'm sure there's more than a couple of applications that will break if you do so.
po0f is offline   Reply With Quote
Old February 11th, 2007   #8
dthury
First Cup of Ubuntu
 
Join Date: Feb 2007
Location: Parker, CO
Beans: 7
Ubuntu 6.06 Dapper
Send a message via MSN to dthury
Lightbulb Re: Setting Python2.5 to Run From The Command Line

I think I've figured out how to get python2.5 "fully functional. Using the update-alternatives "hint" from an earlier response, I did a little research, and learned that "update-alternatives" for python MUST be configured (which it apparently is not, out of the box).

Like others above mentioned, I too experienced "update-alternatives --config python" returned "no alternatives". I then did the following (after su root; sudo before each command may work too):
Code:
update-alternatives --install /usr/lib/python  python /usr/lib/python2.4  10
update-alternatives --install /usr/lib/python  python /usr/lib/python2.5 1
I chose priorities 10 and 1 rather arbitrarily, thinking that Python 2.4 should be the higher/preferred version.

I now get the list of alternatives when I issue the
Code:
update-alternatives --config python,  or
update-alternatives --set python /usr/lib/python2.5
I make my preferred selection. invoke python, and get the selected version. This about the only tests I've done so far, so I don't yet know if there are any gotchas yet!!

Any comments?
dthury is offline   Reply With Quote
Old February 25th, 2007   #9
Tyler Oderkirk
First Cup of Ubuntu
 
Join Date: Jul 2006
Beans: 12
Re: Setting Python2.5 to Run From The Command Line

Quote:
Originally Posted by dthury View Post
Code:
update-alternatives --install /usr/lib/python  python /usr/lib/python2.4  10
update-alternatives --install /usr/lib/python  python /usr/lib/python2.5 1
Hi dthury,

Did you mean to say this instead?
Code:
update-alternatives --install /usr/bin/python  python /usr/lib/python2.4  10
update-alternatives --install /usr/bin/python  python /usr/lib/python2.5 1
/usr/lib/python is a directory of python libraries. /urs/bin/python is the symlink that we want the debian alternatives system to maintain for us I think.

-Tyler
Tyler Oderkirk is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:42 AM.


vBulletin ©2000 - 2009, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry