How can I compile and run a python file (*.py extension)?
If you just want to compile sources, without running them, you can do this
compileall.py
this command will compile python code in that directory recursively
compileall script is usually located in directory like
/usr/local/lib/python2.6
i.e.
(or similar, depending on prefixes set a python configuration)
As Lulu suggests, you should make sure that resulting .pyc and .pyo files are executable by the users you care about.
compileall can also be used as a module
import compileall
compileall.compile_dir(path)