Making Programs Executable

Mike Repass mrepass at insightbb.com
Fri May 31 02:37:44 EDT 2002


seraphim wrote:
> I am reading the Python tutorial, and they say to use '#! /usr/bin/env
> python' as the first line to be able to execute the program withought
> having to type 'python file'. I am getting a bad interpreter error. I
> am running Slackware 8.0 and Red Hat 7.3 as well. Any help would be
> nice.

Is the file's executable bit set?

In order to run a file by typing "./my_program.py", you must make sure 
that the file's "mode" includes correct execution permissions. You can 
view a file's mode by using "ls -al" (the x's stand for executable). To 
make a file executable, execute the following command:

chmod u+x your_file_name_here.py

This adds (+) execute permissions (x) for the user (u) and now you 
should be able to run the program with:

./your_file_name_here.py


Best of luck,

Mike




More information about the Python-list mailing list