When I execute my python script from the command line I have no problems like so:
[rv@med240-183 db]$ python formatdb.py [rv@med240-183 db]$
Add
#!/usr/bin/env python
to the beginning of your script - right now it's trying to execute your script as a bash, that line says "I'm a python script, please use the right interpreter". It's also called a hash-bang line, but it needs to be the first line in your script.