Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'displayed': 0.03; '(at': 0.03; 'subject:Python': 0.04; 'app,': 0.07; 'installed.': 0.07; "shouldn't": 0.07; 'python': 0.07; 'command.': 0.09; 'defined.': 0.09; 'empty,': 0.09; 'kelly': 0.09; 'rename': 0.09; 'subject:library': 0.09; '>>>': 0.12; 'am,': 0.14; 'error:': 0.14; 'wrote:': 0.14; 'defined': 0.15; '"import': 0.16; 'closes': 0.16; 'crashes': 0.16; 'empty),': 0.16; 'normally.': 0.16; '\xa0what': 0.16; 'subject:file': 0.16; 'please?': 0.19; 'command': 0.19; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'seems': 0.21; 'maybe': 0.21; 'header:In-Reply-To:1': 0.22; 'cc:addr:python- list': 0.22; 'thu,': 0.22; 'thats': 0.23; 'calling': 0.25; 'checked': 0.25; 'point,': 0.25; 'creating': 0.26; 'archive': 0.26; 'environment': 0.26; 'later': 0.26; 'work.': 0.27; 'message- id:@mail.gmail.com': 0.28; 'load': 0.28; 'thanks': 0.29; 'installed': 0.29; 'error': 0.29; 'be.': 0.29; 'loaded': 0.29; 'sort': 0.30; 'least': 0.30; 'named': 0.30; 'this.': 0.30; 'cc:addr:python.org': 0.31; 'received:209.85.210.46': 0.31; 'received:mail-pz0-f46.google.com': 0.31; 'it.': 0.31; "can't": 0.31; 'import': 0.32; 'module': 0.33; 'using': 0.34; 'file': 0.35; 'finding': 0.35; 'put': 0.35; 'running': 0.36; 'folder': 0.36; 'missing': 0.36; 'getting': 0.36; 'think': 0.36; 'some': 0.37; 'however': 0.37; 'should': 0.37; 'received:209.85': 0.37; 'run': 0.37; 'received:google.com': 0.38; 'but': 0.38; 'files': 0.38; 'help': 0.39; 'could': 0.39; 'received:209': 0.39; 'how': 0.39; 'add': 0.39; 'works': 0.40; "it's": 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'receive': 0.68; 'message?': 0.84; 'reply!': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=jsikUKQxUYLoXqRLwDEi4TLi1Oiz2iBNKt1GbfELdqo=; b=tzNt1VLTq6gkVoKU51U4n3vqcvtd3HZCGF3x7Qd0jFqpp6QeydPa3pgQDu4UIX2Apn ORYokUkj41HZtSJZrUgFRu8q1PoCMhTA+CrjxiGeyaeno85h+IFC+mfcAcWm+eUeTm+E Wcqo6gkir5LofZCqSbfW+m9E76G5AxhW9Z6n8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=dO9+0q+xmGReKwvW2/DVbwY3p3yXUDl8dzZDS//E7SD6TzSpxABvQwurt+5hWi5lsF s0PTlRY0QMHweMMu/12PgsZ6OktzD/v91qmn6Z5ApBYjcs8Qk6+FJC1Cw+OJ3Fdixmw5 Mo1ov1l3940ouDN7JCGAbR1+C+AC2B+1HNTCQ= MIME-Version: 1.0 In-Reply-To: References: Date: Thu, 5 May 2011 22:34:02 +0200 Subject: Re: Embedding Python's library as zip file From: Wojtek Mamrak To: Ian Kelly Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 59 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1304627647 news.xs4all.nl 81475 [::ffff:82.94.164.166]:56933 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4775 > 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. Maybe I am missing the point, but I think I am not able to do this. When I remove the "Lib" folder and try to run Python.exe, the python console window closes rapidly, so that it is hard to read any message displayed in it and obvioulsy I can't run any python command. Could you clarify this please? > What if you put the zip file in your > PYTHONPATH environment variable? I don't have it defined. Maybe it is because I have 2 different Python interpreters installed. After adding the PYTHONPATH, the Python.exe seems to run normally. Unfortunately I am not able to import Image module (I am using it), which is installed in site-packages/PIL. This happens, because for some reason the site-packages directory is not present in sys.path. After reading the site module description I checked the sys.prefix and sys.exec_prefix, which are both empty, when the Lib folder is loaded from the zip archive. Thats why site-packages is not added to sys.path. Of course I can add site-packages directory to the sys.path by myself (yet I don't know why sys.prefix and sys.exec_prefix are empty), however how to deal with the PYTHONPATH, which is required to load site.py and hence has to be defined at the very beginning? thanks for your help 2011/5/5 Ian Kelly : > On Thu, May 5, 2011 at 4:55 AM, Wojtek Mamrak 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. =A0After 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. =A0What 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. =A0It works for me (at least with Python.exe) creating > the zip archive using 7-Zip. >