Embedding Python's library as zip file

Ian Kelly ian.g.kelly at gmail.com
Thu May 5 11:36:39 EDT 2011


On Thu, May 5, 2011 at 4:55 AM, Wojtek Mamrak <tacyt1007 at gmail.com> wrote:
> Thanks for the reply!
>
>> Can you import from zip files when running the Python.exe interpreter?
> When I zip the folder "Lib" into Python27.zip and later rename it and
> try to run the python.exe, I receive an error:
> "Import error: no module named site"

That means it's not finding it.  After startup, try adding the zip
file to your sys.path and then do "import site" at the command line,
and it should work.

>> Are you getting any sort of error message?
> When I run my app, it crashes while calling Py_Initialize(). The
> console closes suddenly.

Hm, that definitely seems odd.  What if you put the zip file in your
PYTHONPATH environment variable?

> Is it necessary to create zip archive using zipfile.PyZipFile?

It shouldn't be.  It works for me (at least with Python.exe) creating
the zip archive using 7-Zip.



More information about the Python-list mailing list