How to create Standalone PYC File

Chris Rebert clp2 at rebertia.com
Wed Mar 4 14:43:50 EST 2009


On Wed, Mar 4, 2009 at 11:38 AM, Rohan Hole <rohanhole31 at gmail.com> wrote:
> I have .py file which uses some third party modules like egg files, like
> simplejson and python-twitter ,
>
> ----- start of file  -----
>
> import ConfigParser
> import getopt
> import os
> import sys
> import twitter
>
>
> when i compile this py file using compile module , i get .pyc file . Now my
> question is , if i run .pyc file on another computer containing only python
> installed , will it run ?

No.

> or do i need to install 3rd party lib again on
> that computer ?

Yes. The .pyc /only/ contains the code for the .py file it was
generated from; it does /not/ contain the code for any imported
libraries.

> Anyone know how to make program lib independent , something
> called embedded into one file only ?

py2exe (http://www.py2exe.org/) is the usual tool for this on Windows.
It takes a Python program and bundles it together with the Python
executable and any imported libraries to yield a standalone .exe

Cheers,
Chris

-- 
I have a blog:
http://blog.rebertia.com



More information about the Python-list mailing list