[Pythonmac-SIG] Yet another problem with path

Christopher Barker Chris.Barker at noaa.gov
Mon Jul 14 21:10:22 CEST 2008

Pascal Bompard wrote:
> I suppose the next best strategy should be to look into using a terminal 
> shortcut to at least make the "cd" to the directory a bit less painful.

If you drag and drop a folder from the Finder to the terminal, its path 
will get pasted in.

I also really like the "Open Terminal here" applet, so you can easily 
open a terminal already cd'd to the folder you're looking at in the finder.

>>> The problem remains though, that every time I want to run a script in 
>>> that directory, I'd have to type out the entire path, which is not 
>>> ideal.
>>> Surely there must be a work around to allow me to only type in the 
>>> script name, at least I assume there must be?

If you have scripts you want to run from anywhere, make them executable:

chmod a+x MyScript.py

and put:

#!usr/bin/env python

at the top.

Then either:

put them in a standard place that should be on your PATH, like:


or put the path to your scripts in your PATH -- often people use:


Another trick is to put a symbolic link to your script in /usr/local/bin:

sudo ls -s /Users/pascal/Documents/Python/Dev/myapps/test.py \ 

That will make it look to the system like it's in /usr/local/bin, but it 
points to the original, so if you edit that, the edited version will be 
run in the future.

do buy a book or surf the web for info about using the terminal on OS-X 
-- it's a great skill to have.


Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov

More information about the Pythonmac-SIG mailing list