executing python code

Michael Fuhr mfuhr at fuhr.org
Fri Nov 5 18:35:50 EST 2004


Darren Dale <dd55 at cornell.edu> writes:

> Yes, I did chmod, the script is in the current directory.
>  
> $ mycode.py
> bash: mycode.py: command not found
>
> I just tried:
>
> $ ./mycode.py
>
> and that will execute.

That means the directory isn't in your PATH environment variable,
neither as a full path (/path/to/the/directory) nor as ".", which
means the current directory.  For security reasons it's usually
wise to leave "." out of your PATH, so if you don't want to type
./mycode.py each time then put your scripts in a directory that
PATH knows about.  As others have mentioned, a common place for
a user's private scripts is in ~/bin, that is, the "bin" directory
under your home directory.  If it doesn't exist then you can use
mkdir to create it, and if it's not in your PATH then you'll need
to add it.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



More information about the Python-list mailing list