On Tue, 3 Aug 2004, Darren Dale wrote:
Is there a place to put python programs so I dont have to refer to the
absolute path everytime I want to call them? For example:
if I am in /home/me and want to execute:
python /home/me/python/export.py temp.dat
what could I do so this will work:
python export.py temp.dat
The easiest way to do this is to make the script executable directly:
1) Add the line '#!/usr/bin/env python' or '#!/path/to/python' (usually
/usr/bin/python or /usr/local/bin/python) to the top of your script, as
for a shell script.
2) Set your script's executable bit using 'chmod a+x'.
3) Stick your script, or a link to it, in something touched by the PATH
environment variable (such as /usr/local/bin) or, if you prefer, add your
script's directory to PATH (with a line like 'export
PATH=~/my/script/directory:$PATH' in your .bashrc file).
Then you can execute your script just by specifying its name.