rbrtl rbrtl - 5 months ago 32
Bash Question

Virtualenv not working with executable .py file

I was having a problem getting a python script to run in the shell:

$ chmod u+x scratch.py
$ ./scratch.py
./scratch.py: line 3: import: not found

What am I doing wrong here?


# /usr/bin/env python

import sys

print sys.version_info


You're missing the shebang's ! at the top of your script, so the shell is not recognizing your script as a Python script:

#!/usr/bin/env python