PATH not known in Windows?

Thread Solved
Reply

Join Date: Jan 2007
Posts: 2
Reputation: dams is an unknown quantity at this point 
Solved Threads: 0
dams dams is offline Offline
Newbie Poster

PATH not known in Windows?

 
0
  #1
Jan 17th, 2007
Hello,

I am new to Python and find it really nice.
But I can not launch an executable file using only its name. I have to give its whole path. I expected that the PATH environment variable is known by Python and that it could retrieve the full path itself...
I use Windows XP, Python 2.5 and os.spawnl to launch the executable file.
Thanks in advance for your help!

dams
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,862
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 870
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: PATH not known in Windows?

 
0
  #2
Jan 17th, 2007
Write a small Python program like the one below and save it as PrintHello.py ...
  1. print "Hello"
  2.  
  3. raw_input("Press Enter to go on ... ")
Now run this program ...
  1. import subprocess
  2.  
  3. subprocess.call(["Python.exe", "PrintHello.py"])
It seems to find Python.exe without any problems.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 977
Reputation: woooee is a jewel in the rough woooee is a jewel in the rough woooee is a jewel in the rough 
Solved Threads: 273
woooee woooee is offline Offline
Posting Shark

Re: PATH not known in Windows?

 
0
  #3
Jan 17th, 2007
This will print your PYTHONPATH. If the path you want is not listed, and it shouldn't be because your program isn't found, then you have to use sys.path.append to add it.
  1. import sys
  2. path_list= sys.path
  3. for eachPath in path_list :
  4. print eachPath
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,205
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 130
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

Re: PATH not known in Windows?

 
0
  #4
Jan 18th, 2007
Originally Posted by woooee View Post
This will print your PYTHONPATH. If the path you want is not listed, and it shouldn't be because your program isn't found, then you have to use sys.path.append to add it.
  1. import sys
  2. path_list= sys.path
  3. for eachPath in path_list :
  4. print eachPath
PYTHONPATH is only used by Python internally to find modules etc.
This person wants to use Window's Environment Variable.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 2
Reputation: dams is an unknown quantity at this point 
Solved Threads: 0
dams dams is offline Offline
Newbie Poster

Re: PATH not known in Windows?

 
0
  #5
Jan 18th, 2007
Thanks to you all for your quick answer!
The method with subprocess.call is exactly what I want and runs perfectly.
Bye,
Dams
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC