How do I get linux to automatically run my python script in the Python interpreter?

linux, python

Solution

You need to make the script executable using

chmod +x Standalone.py

Usually, the current directory is not searched for executable files, so you need to use

./Standalone.py

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

Problem

I've decided that it would be good for me to move outside of my .NET bubble and start experimenting with other technologies. I have Ubuntu12 running and python2.7 and 3.2 are installed. I can run code directly in the interpreters. I have a basic script on the filesystem called Standalone.py: ``` #!/usr/bin/env python3.2 import sys print("this is a standalone script.") ``` When I'm at my bash prompt I type `$ python3.2 Standalone.py`. I get a response saying `this is a standalone script`. But when I type `$ Standalone.py` then it tells me that the command is not found. How do I run such scripts? Thanks for any help. update I changed the permissions of Standalone.py to 755. Then I ran the command: ``` $ ./Standalone.py ``` and received the message: ``` : No such file or directory ``` I then switched the permissions of Standalone.py back to 644. Then when I ran ``` $ ./Standalone.py ``` I received the message ``` -bash: ./Standalone.py: Permission denied ``` Is there something I'm missing?

Original source