#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    6
    Rep Power
    0

    ok... got an easy question


    ok installed the newest version of python on my linux box and the shebang line (#!/usr/bin/env python) is still executing the old version of python (1.5) how can i change /usr/bin/env so that it executes the correct version?
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    If you type "which python" do you get the path to the old version? All you have to do is update the environment variable which points at Python (don't ask me how ), if this doesn't work you could always use the full path instead of "#!/usr/bin/env python"

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14
    env doesn't actually use an environment variable for executables like Python, AFAIK. It looks for the first "python" it can find in yout PATH variable. So you need to do something like this:

    Code:
    tom@piglet tom $ which python | xargs ls -l
    lrwxrwxrwx    1 root     root            7 Sep 14 01:48 /usr/bin/python -> python2
    tom@piglet tom $ ls -l /usr/bin/python2
    lrwxrwxrwx    1 root     root            9 Sep 14 01:48 /usr/bin/python2 -> python2.2
    tom@piglet tom $ ls -l /usr/bin/python2.2
    -rwxr-xr-x    1 root     root       883192 Sep 14 01:48 /usr/bin/python2.2
    Then you can track down the location of your new Python binary, and change any symlinks to point to the right one.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    6
    Rep Power
    0
    Originally posted by netytan
    All you have to do is update the environment variable which points at Python (don't ask me how )

    Mark.
    that's actually exactly what i was asking....





    Originally posted by telex4


    Then you can track down the location of your new Python binary, and change any symlinks to point to the right one.
    ok... but how?
  8. #5
  9. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    i'm kinda new to *nix so i have NO idea. You might get a better responce from the Linux forum? or just hang around for Telex to come back , i think he'll be able to answer your question better than i can.. plus i'd be interested in the answer.

    Mark.
    programming language development: www.netytan.com Hula

  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    13
    Perhaps a better question is why you even bother having 1.5 installed ... it's very very very outdated.
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    6
    Rep Power
    0
    it was pre installed...
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    13
    If you don't need it, why keep it?
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    29
    Rep Power
    0
    sounds like to me you didnt install it from the ports.

    if i was you i would deinstall all versions of python, do a ports update then install from ports AND better still install portupgrade and learn it


    Originally posted by Strike
    Perhaps a better question is why you even bother having 1.5 installed ... it's very very very outdated.
  18. #10
  19. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,626
    Rep Power
    4247
    echo $PATH

    That should print your current path variable. To append a new value to the beginning, you should do something like this (assuming a bash shell, which is default for RedHat):

    export PATH=/new/path:${PATH}

    basically ${PATH} will pull the old path into the expression. Now if you put the above line into your .bashrc file, then it should be set every time you log in. HTH
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    6
    Rep Power
    0
    thank you Scorpions4ever
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    13
    sissy ... ports? He said it was a Linux machine. The only port-like thing that I am familiar with there would be portage ... and you wouldn't use portupgrade with that.
  24. #13
  25. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14
    Originally posted by Caelestis

    ok... but how?
    Oops, sorry, I should have said.

    First, you need to remove the old symlink (assuming it was a symlink, which you should have determined by doing what I said above... if /usr/bin/python seems to point to something, then it is a symlink (a symbolic link, like a windows shortcut)).

    Then, you need to create a new symlink that will point to the location of the new python binary. You'll need to find that binary first too.

    Lots to do


    (find the new python binary)

    Code:
    ls /usr/bin/python*
    (that will give you a list of binaries that begin with "python", which should include something like "python2.2")


    (remove the old symlink)

    Code:
    rm /usr/bin/python

    (make the new symlink)

    Code:
    ln -s /usr/bin/python2.2 /usr/bin/python
    (where "/usr/bin/python2.2" is the path to your new python binary)



    I hope that helps. If you're still confused, feel free to ask for more help You might also want to learn a little about the basics of UNIX and GNU/Linux if you're going to be doing a lot of Python coding; or you may not If you do, try www.NewToLinux.org.uk

IMN logo majestic logo threadwatch logo seochat tools logo