importing packages from a zip file
Dieter Maurer
dieter at handshake.de
Fri Jul 1 14:22:19 EDT 2005
Scott David Daniels <Scott.Daniels at Acm.Org> writes on Wed, 29 Jun 2005 10:36:29 -0700:
> Peter Tillotson wrote:
> ...
> > 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
The alternative is to use a "zipimporter" (from module "zipimport")
and use the "importer protocol" (documented in a PEP).
More information about the Python-list
mailing list