Re: [cx-freeze-users] cx_freeze, py2app both have problems to deal with reload()
Brought to you by:
atuining
From: Bob I. <bo...@re...> - 2005-07-13 22:21:49
|
On Jul 13, 2005, at 9:22 AM, Huaicai Mo wrote: > One of my python files for the package has something like: > > > > 110: if some_condition: > > 111: import abc > > 112: reload(abc) > > 113: from abc import other_stuff > > =85=85.. > > > > I used cx_freeze, py2app, py2exe to create packages for Linux, Mac =20 > OS X and Windows respectively. All of them will get =93ImportError: =20= > No module named abc=94 on line 111=94. Since py2app and py2exe both = use =20 > a zip file to include all those needed modules, if I unzip the file =20= > into a folder called =93site-packages.zip=94 or =93library.zip=94 and =20= > remove or rename the zip file, then it works. > > > > cx_freeze doesn=92t have such a zip file, so the above trick doesn=92t = =20 > work. Can anybody explain the problem and do you know a workaround =20 > for this problem for cx_freeze? The zip importer doesn't support reload properly. It's not fixable =20 (without upgrading Python, since it's compiled-in). Since the only =20 import hook in stock Python is the zip importer, the easy way to =20 check this is: if some_condition: import abc if getattr(abc, '__loader__') is None: reload(abc) .... -bob |