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"?
Type "start [filename.exe]" into Command Prompt, replacing "filename" with the name of your selected file. Replace "[filename.exe]" with your program's name. This allows you to run your program from the file path.
To make the program executable from anywhere for all users, we can add it to the global profile settings in /etc/profile. We should note that /etc/profile and ~/. bash_profile are specific to the Bash shell. Other shells will likely use different locations.
You just need to add the path C:\Python to your Path Environment Variable which can be modified from the Advanced tab of the System Properties control panel.
To eliminate the need to type python
before your script, you can do the following:
python.exe
to your system PATH environment variable, if it's not already there.;.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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With