importing packages from a zip file

Scott David Daniels Scott.Daniels at Acm.Org
Wed Jun 29 19:36:29 CEST 2005


Peter Tillotson wrote:
> ... With the file system
> 
> base/
> __init__.py
>     branch1/
>     __init__.py
>     myModule.py
> 
> At the same time its possible to store modules in a flat zip-file and
> import modules with the following.
> 
> from myZip.zip import myModule.py

Does this work for you?  It gives me a syntax error.

Typically, put the zip file on the sys.path list, and import modules
and packages inside it.  If you zip up the above structure, you can use:

     sys.path.insert(0, 'myZip.zip')
     import base.branch1.myModule

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list