Results 1 to 10 of 10

Thread: Setting Python2.5 to Run From The Command Line

  1. #1
    Join Date
    Dec 2006
    Beans
    67

    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

  2. #2
    Join Date
    Nov 2005
    Beans
    51
    Distro
    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

  3. #3
    Join Date
    Oct 2004
    Location
    Germany, Old Europe
    Beans
    379
    Distro
    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

  4. #4
    Join Date
    Dec 2006
    Beans
    67

    Re: Setting Python2.5 to Run From The Command Line

    Ok. Thanks for your help. It works now.

  5. #5
    Join Date
    Feb 2005
    Location
    Maine, USA
    Beans
    286

    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.

  6. #6
    Join Date
    Oct 2006
    Location
    Austin, Texas
    Beans
    2,715

    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.

  7. #7
    Join Date
    Sep 2006
    Beans
    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.

  8. #8
    Join Date
    Dec 2006
    Beans
    67

    Re: Setting Python2.5 to Run From The Command Line

    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.
    Yes, I just found out that was a really bad idea. I thought that since I just wanted to use it to run my own programs in python2.5 it wouldn't be a problem but it turns out that if you change the symbolic link to python2.5 Add/Remove programs will not run correctly because it does not work with python2.5! It looks like this is because there is no AppInstall package in /usr/lib/python2.5/site-packages but there is in /usr/lib/python2.4/site-packages so python doesn't find the required AppInstall package when you try to run Add/Remove programs (probably could have just copied the required packages to /usr/lib/python2.5/site-packages from /usr/lib/python2.4/site-packages but I didn't try it). Anyway, I changed the symbolic link back to python2.4 and added the alias as po0f suggested and it works fine now.

    Thanks

  9. #9
    Join Date
    Feb 2007
    Location
    Parker, CO
    Beans
    10
    Distro
    Ubuntu 6.06 Dapper

    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?

  10. #10

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •