Python executable

Jules Dubois not-even at dispsable.address.this.time
Tue Sep 6 01:06:57 EDT 2005


On Monday 05 September 2005 21:54, presentt <presentt at gmail.com>
(<1125978845.080791.14520 at g43g2000cwa.googlegroups.com>) wrote:

> So I created a file named helloworld.py, and put in it:
> 
> #! /usr/bin/env python
> print "Hello, world!"
> 
> and then used
> $ chmod +x helloworld.py
> to set the permissions.  Finally, I went to my terminal and typed
> $ helloworld.py
> but I was given the bash: helloworld.py: command not found error.
> 
> Can someone tell me
> (1)Am I right in saying that something is directly executable if I can
> enter the filename in the command line and it runs?

Almost.  For more information, you might read about the PATH variable.

> (2)Am I setting up the script to be directly executable correctly?

Yes.

> and (3)Am I trying to run the directly executable script correctly?

No.  The best (safest) method is to type 

  ./helloworld.py

to tell your shell that the script is in the current directory.



More information about the Python-list mailing list