Use Enthought Canopy to run a python script without specifying its full path
Question: 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](http://stackoverflow.com/questions/10002291/how-to-run-a-python-script-
portably-without-specifying-its-full-path), 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?


Answer: BTW, it's probably a typo, but just to make sure you should be using the
module name, not the file name, with the `-m` option. For example, `python -m
run`

If that is not the problem then make sure that the python that is used in your
option 2 is the python located in your Canopy User virtual environment. You
can use the `which` command to verify that. For example:

` $ which python
/Users/YourUserId/Library/Enthought/Canopy_64bit/User/bin/python `

If that is not what you get then you can either add that bin folder to the
beginning of your `PATH` environment variable, or you can activate that
virtual environment like this:

` source /Users/YourUserId/Library/Enthought/Canopy_64bit/User/bin/activate `

