The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
ok... got an easy question
Discuss ok... got an easy question in the Python Programming forum on Dev Shed. ok... got an easy question Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

September 27th, 2003, 11:12 PM
|
|
Junior Member
|
|
Join Date: May 2003
Posts: 6
Time spent in forums: < 1 sec
Reputation 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?
|

September 28th, 2003, 02:17 AM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
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
|

September 28th, 2003, 04:47 AM
|
 |
Wacky hack
|
|
Join Date: Apr 2001
Location: London, England
Posts: 513
Time spent in forums: 1 h 38 m 37 sec
Reputation Power: 13
|
|
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.
|

September 28th, 2003, 06:47 AM
|
|
Junior Member
|
|
Join Date: May 2003
Posts: 6
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Quote: 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....
Quote: 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?
|

September 28th, 2003, 09:09 AM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
 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.
|

September 29th, 2003, 09:19 AM
|
|
Contributing User
|
|
Join Date: Dec 2001
Location: Houston, TX
Posts: 383
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 12
|
|
|
Perhaps a better question is why you even bother having 1.5 installed ... it's very very very outdated.
|

September 29th, 2003, 03:58 PM
|
|
Junior Member
|
|
Join Date: May 2003
Posts: 6
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
it was pre installed...
|

September 29th, 2003, 04:01 PM
|
|
Contributing User
|
|
Join Date: Dec 2001
Location: Houston, TX
Posts: 383
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 12
|
|
|
If you don't need it, why keep it?
|

September 29th, 2003, 05:59 PM
|
|
Registered User
|
|
Join Date: Jul 2003
Posts: 29
Time spent in forums: 2 h 48 m 25 sec
Reputation 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
Quote: Originally posted by Strike
Perhaps a better question is why you even bother having 1.5 installed ... it's very very very outdated. |
|

September 29th, 2003, 07:54 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
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
|

September 29th, 2003, 11:08 PM
|
|
Junior Member
|
|
Join Date: May 2003
Posts: 6
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
thank you Scorpions4ever
|

September 29th, 2003, 11:59 PM
|
|
Contributing User
|
|
Join Date: Dec 2001
Location: Houston, TX
Posts: 383
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 12
|
|
|
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.
|

September 30th, 2003, 03:51 AM
|
 |
Wacky hack
|
|
Join Date: Apr 2001
Location: London, England
Posts: 513
Time spent in forums: 1 h 38 m 37 sec
Reputation Power: 13
|
|
Quote: 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)
(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
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|