views:

186

answers:

3

I can best explain my question with an example. I recently downloaded Python for Windows, installed to C:\Python. So if I'm in folder X that contains myscript.py, and I want to invoke it, I have to call this:

> C:\Python\python.exe myscript.py

But it would be super-cool if I could just do this, from within any folder:

> python myscript.py

How do I make that "global"?

+3  A: 
Mark Biek
That did the trick; thank you!
SoaperGEM
I'm clicking on the buttons in your answer but they don't work, please advise :)
RedFilter
@OrbMan You almost made me snarf Diet DP.
Mark Biek
+1  A: 

Another possible solution would be to add an entry to the registry:

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\python.exe

and then set the (default) value of that to the path (+ program name) where your python.exe resides, e.g. C:\Python\Python.exe.

That way, you can call python.exe from anywhere - no path or other stuff needed.

Marc

marc_s
All applications I write have installers that adds an app path.
Andreas Rejbrand
A: 

To eliminate the need to type python before your script, you can do the following:

  1. Add python.exe to your system PATH environment variable, if it's not already there.
  2. Add ;.py to the end of your PATHEXT system environment variable.

Then, instead of typing

> C:\Python\python.exe myscript.py

or

> python myscript.py

you can just type

> myscript.py
Patrick Cuff