I want to be able to run a python script at the command line using Enthought Canopy, but I don't want to specify the full path to the script.
As I see it, there are two options.
Option 1: Make the python script an executable, add #!/usr/bin/env python
to the top of the script, and put the directory containing the script on my $PATH
. Now I can execute the script like this:
$ run.py
Option 2: As suggested by Andrew Clark in another SO post, just put the directory containing the script on my $PYTHONPATH
. Then I can execute the script like this:
$ python -m run.py
The -m
causes python to search the $PYTHONPATH
.
I prefer Option 2, and it works fine with the system python on my mac (v2.7.2), but I cannot get it to work with Enthought Canopy. I can load Canopy python and import modules in the same directory as run.py
, so I know that I have the path correct. I just cannot execute the script from the command line. Is this a bug or am I doing something wrong?