Helpful Information
 
 
Category: Python Programming
Compiler?

This may seem like a wierd newbie question to be asking, but here goes.

Is it possible to compile Python? I know PHP can be thanks to Zend but is there any Python equivilant?

If I recall correctly, the Python interpreter comes with a built in byte-compiler. You might want to try this (assuming that you want to byte compile a file called foobar.py):



#!/usr/bin/python

import py_compile
py_compile.compile("foobar.py")

This will create a byte-compiled python file called foobar.pyc. Is this what you're looking for?

If you want to make Python programs run stand-alone, take a look at the Python FAQ (http://www.python.org/cgi-bin/faqw.py?req=home), and search for Freeze (http://www.python.org/cgi-bin/faqw.py?query=freeze&querytype=simple&casefold=yes&req=search).

If you want to compile them, use Scorpions4ever's answer.

Standalone is what I was looking for, sorry if I was vague. Thank you both for the info.

You should also have a look at http://starship.python.net/crew/theller/py2exe/

It allows you to create standalone *.exe files (command line and Windowed versions). Pretty cool stuff :)










privacy (GDPR)