LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 12-08-2007, 10:52 AM   #1
rocka
Member
 
Registered: Jan 2007
Posts: 30

Rep: Reputation: 0
Change default Python version


I am running Debian Etch 4.0 and I am trying to change the default python version to 2.5. I used apt-get install python2.5 and the package installed successfully, but typing:
python -V
still gives me:
Python 2.4.4

Any help would be greatly appreciated.
 
Old 12-09-2007, 04:18 AM   #2
Vookimedlo
Member
 
Registered: Jul 2004
Location: Czech Republic - Roudnice nad Labem
Distribution: Debian
Posts: 253

Rep: Reputation: 34
Hi,

Have you tried update-alternatives? This should be a standard way how to switch default version of given program between multiple versions.
 
Old 12-09-2007, 06:18 AM   #3
rocka
Member
 
Registered: Jan 2007
Posts: 30

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Vookimedlo View Post
Hi,

Have you tried update-alternatives? This should be a standard way how to switch default version of given program between multiple versions.
I have tried: "update-alternatives --config python"
that gives me:
"No alternatives for python."
 
Old 12-09-2007, 11:32 AM   #4
makuyl
Senior Member
 
Registered: Dec 2004
Location: Helsinki
Distribution: Debian Sid
Posts: 1,107

Rep: Reputation: 54
How about changing the symlink, i.e:
Code:
ln -s /usr/bin/python2.4  /usr/bin/python
My setup:
Code:
:~$ls -l $(which python)
lrwxrwxrwx 1 root root 9 Jun  2  2007 /usr/bin/python -> python2.4
:~$ls -l /usr/bin/python*
lrwxrwxrwx 1 root root       9 Jun  2  2007 /usr/bin/python -> python2.4
lrwxrwxrwx 1 root root      16 Jun  2  2007 /usr/bin/python-config -> python2.4-config
-rwxr-xr-x 1 root root  946284 Oct 19  2006 /usr/bin/python2.3
-rwxr-xr-x 1 root root 1018188 Aug 16 03:05 /usr/bin/python2.4
-rwxr-xr-x 1 root root    1276 Aug 16 03:04 /usr/bin/python2.4-config
-rwxr-xr-x 1 root root 1149812 Aug 17 01:52 /usr/bin/python2.5
 
Old 12-09-2007, 02:09 PM   #5
rocka
Member
 
Registered: Jan 2007
Posts: 30

Original Poster
Rep: Reputation: 0
Thank you for your reply. Tried it, didn't help:

Code:
ln -s /usr/bin/python2.4  /usr/bin/python
ln: creating symbolic link `/usr/bin/python' to `/usr/bin/python2.4': File exists
:~# ln -s /usr/bin/python2.4  /usr/bin/python2.5
ln: creating symbolic link `/usr/bin/python2.5' to `/usr/bin/python2.4': File exists
Code:
:~# ls -l $(which python)
lrwxrwxrwx 1 root root 9 2006-07-22 13:49 /usr/bin/python -> python2.4
~# ls -l /usr/bin/python*
lrwxrwxrwx 1 root root       9 2006-07-22 13:49 /usr/bin/python -> python2.4
-rwxr-xr-x 1 root root 1015360 2007-04-05 20:12 /usr/bin/python2.4
-rwxr-xr-x 1 root root 1139848 2006-12-09 14:37 /usr/bin/python2.5
Code:
:~# python -V
Python 2.4.4
Did I do something wrong? Any other suggestions. I also tried to remove python 2.4 and re-install python 2.5. Still after this it's listing python 2.4.4 as the active.

Last edited by rocka; 12-09-2007 at 02:17 PM.
 
Old 12-09-2007, 04:31 PM   #6
makuyl
Senior Member
 
Registered: Dec 2004
Location: Helsinki
Distribution: Debian Sid
Posts: 1,107

Rep: Reputation: 54
Well, if the link exists, remove it: "rm /usr/bin/python". Then make the link with ln -s
In my example output the files with a "->" pointing to a real file, are links. The links you can remove to change them.
You have python pointing to python2.4 . If you want 2.5 do:
rm /usr/bin/python
ln -s /usr/bin/python2.5 /usr/bin/python
 
Old 12-09-2007, 06:05 PM   #7
rocka
Member
 
Registered: Jan 2007
Posts: 30

Original Poster
Rep: Reputation: 0
That sure did work. Thank you very much makuyl
 
Old 12-10-2007, 01:30 PM   #8
makuyl
Senior Member
 
Registered: Dec 2004
Location: Helsinki
Distribution: Debian Sid
Posts: 1,107

Rep: Reputation: 54
You're welcome.
PS: you can't link a binary (executable) to another binary. Symbolic links are like windows (or any os's) shortcuts, so this:
Quote:
Originally Posted by rocka View Post
Code:
:~# ln -s /usr/bin/python2.4  /usr/bin/python2.5
ln: creating symbolic link `/usr/bin/python2.5' to `/usr/bin/python2.4': File exists
won't work as both those files are binaries. You create a link to a binary as you did, or you can create several link layers as in link->link->binary.
Code:
man ls
type "q" to quit.
 
1 members found this post helpful.
Old 04-11-2008, 05:34 PM   #9
jameslaw
Member
 
Registered: Nov 2005
Location: Trento, Italy
Distribution: Debian:testing, Ubuntu
Posts: 33

Rep: Reputation: 15
Changing the link may work, but I'm not satisifed this if the "official" way to change the default python version. If I look in my /usr/bin, I have python2.4 and python2.5 installed and 2.4 is the default.

lrwxrwxrwx 1 root root 9 2007-06-13 18:32 /usr/bin/python -> python2.4
-rwxr-xr-x 1 root root 1021516 2008-03-11 17:17 /usr/bin/python2.4
-rwxr-xr-x 1 root root 1173364 2008-03-08 20:42 /usr/bin/python2.5

However, in that same dir there is also:

lrwxrwxrwx 1 root root 29 2007-06-13 18:32 /usr/bin/pyversions -> ../share/python/pyversions.py

If I look in /usr/share/python, I have:

-rw-r--r-- 1 root root 288 2007-05-03 21:28 debian_defaults
-rwxr-xr-x 1 root root 12158 2007-05-16 23:19 pyversions.py

And, the contents of debian_defaults is:
---begin---
[DEFAULT]
# the default python version
default-version = python2.4

# all supported python versions
supported-versions = python2.4, python2.5

# formerly supported python versions
old-versions = python2.3

# unsupported versions, including older versions
unsupported-versions = python2.3
---end---

So, how do I change the default version so that I know the debian management system knows what is going on?
 
Old 03-31-2009, 04:37 AM   #10
arctan1701
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Rep: Reputation: 1
Quote:
Originally Posted by jameslaw View Post
Changing the link may work, but I'm not satisifed this if the "official" way to change the default python version. If I look in my /usr/bin, I have python2.4 and python2.5 installed and 2.4 is the default.

[snip]

So, how do I change the default version so that I know the debian management system knows what is going on?
this is what you are looking for:

http://codeghar.wordpress.com/2009/0...ves-in-debian/
 
1 members found this post helpful.
Old 03-31-2009, 09:38 AM   #11
Telemachos
Member
 
Registered: May 2007
Distribution: Debian
Posts: 754

Rep: Reputation: 59
Quote:
Originally Posted by arctan1701 View Post
That blog post recommends using sudo. On a default Debian setup, sudo is not enabled. (The blog author may be coming from an Ubuntu background, or they may like this kind of setup.) So, for anyone who tries this: substitute su.

More generally, I would not recommend changing the links in /usr/bin by hand, and there are other ways to skin this cat. If you really wanted a specific version of Python to be found as the default (ie, simply by typing python), I would prefer this: (1) make a symlink to $HOME/bin/python and then (2) make sure that $HOME is earlier in my $PATH than /usr/bin. This is cleaner, I think, and it avoids messing with the system defaults.

Last edited by Telemachos; 03-31-2009 at 09:39 AM.
 
Old 03-31-2009, 10:01 AM   #12
vlademir
Member
 
Registered: Jan 2009
Location: The Netherlands
Distribution: Centos,Ubuntu,Mandriva,Suse11.1
Posts: 86

Rep: Reputation: 17
Hi,

Please see this link surely will help you
http://forums.freebsd.org/showthread.php?t=1390
 
Old 03-31-2009, 02:26 PM   #13
makuyl
Senior Member
 
Registered: Dec 2004
Location: Helsinki
Distribution: Debian Sid
Posts: 1,107

Rep: Reputation: 54
If you don't want to mess with the symlinks, you can use the debian way update-alternatives without sudo
Code:
:~# update-alternatives --install /usr/bin/python python /usr/bin/python2.4 10
:~# update-alternatives --install /usr/bin/python python /usr/bin/python2.5 20
As a side note, why are you necro posting?

Last edited by makuyl; 03-31-2009 at 02:29 PM.
 
Old 03-31-2009, 06:26 PM   #14
Telemachos
Member
 
Registered: May 2007
Distribution: Debian
Posts: 754

Rep: Reputation: 59
Quote:
Originally Posted by makuyl View Post
As a side note, why are you necro posting?
Damn. I can't speak for Arctan1701, but I necro-posted (!) because this thread ended up on the top of the Debian forum (after Arctan bumped it) and the sudo advice bugged me. I have to start checking dates more carefully.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: change of the default python version (status) LXer Syndicated Linux News 0 08-08-2006 03:33 PM
python problem - compiled from source - python -V still showing old version txm123 Linux - Newbie 1 02-15-2006 12:05 PM
How to change system default dbus to version 0.23??? okeyla Linux - Newbie 0 10-27-2005 03:31 AM
How to change the gcc compiler's default version? aladin Linux - Software 8 10-09-2005 09:07 PM
Need help in installing new python version.... Robert135 Linux - Software 1 12-30-2004 01:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 09:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration