Need compile python code

MonkeeSage MonkeeSage at gmail.com
Sat Sep 23 15:12:11 EDT 2006


mistral wrote:
> this not work for me, show compilation error.  Is there simple way
> compile pythone file? its absolutely unclear with command line. Just
> show me exact command I need run(from python interactive shell?)

OK...

# cd to where the file.py is
$ cd /some/dir

# start python interactively, enable optimized compiling
$ python -O
...

# import your file.py -- if this doesn't work then
# your file has errors and will not compile --
# if it works then your file is now compiled --
# file.pyo should now exist with file.py
>>> import file

# you can also do it explicitly --
# import the compiler
>>> import py_compile
>>> py_compiler.compile('file.py')

If that still doesn't work, show us the error, or we can't help you
very easily.

Regards,
Jordan




More information about the Python-list mailing list