Adding to Bryan's answer, if you simply want to compile a file or a bunch of files from a terminal, the py_compile module can be executed as a script in the following manner:
python -m py_compile fileA.py fileB.py fileC.py ...
Adding to Bryan's answer, if you simply want to compile a file or a bunch of files from a terminal, the py_compile module can be executed as a script in the following manner:
python -m py_compile fileA.py fileB.py fileC.py ...
Also be aware that you don't need to compile a .py file to run it. Python is an interpreted language, and you can run the scripts directly, either using:
python hello.py
Or make your script executable by adding #!/usr/bin/env python to the top of the script, making the file executable with chmod +x hello.py and then running:
./hello.py
The fact that Python internally compiles your .py script to bytecode .pyc files for performance reasons is an implementation detail, and unless you have a strong reason to do so, let python itself decide when and if to compile.
The py_compile module provides a function to generate a byte-code file from a source file, and another function used when the module source file is invoked as a script.
python -m py_compile fileA.py fileB.py fileC.py
Yes, there is module compileall. Here's an example that compiles all the .py files in a directory (but not sub-directories):
python -m compileall -l myDirectory
python yourfile.py
You have to have python installed first. It will automatically compile your file into a .pyc binary, and then run it for you. It will automatically recompile any time your file changes.
http://www.python.org/download/
Python compiles its files to bytecode before executing them. That means you have to have a Python interpreter installed on the target machine.
If you don't want to install Python on the target machine use py2exe, py2app or something similar.