From: <ejo...@ea...> - 2007-02-01 21:11:43
|
I am off to sort of a rough start trying to use py2exe to build a wxPython GUI and distribute it as a single Windows executable. Running the build seems to go OK, but when attempting to run the resulting executable, I get the following error (put into a logfile by the exe): C:\Python24\Lib\site-packages\py2exe\samples\singlefile\gui\dist\test_wx.exe\zipextimporter.py:82: DeprecationWarning: The wxPython compatibility package is no longer automatically generated or activly maintained. Please switch to the wx package as soon as possible. Traceback (most recent call last): File "test_wx.py", line 1, in ? File "zipextimporter.pyo", line 82, in load_module File "wxPython\__init__.pyo", line 15, in ? File "zipextimporter.pyo", line 82, in load_module File "wxPython\_wx.pyo", line 3, in ? File "zipextimporter.pyo", line 82, in load_module File "wxPython\_core.pyo", line 15, in ? File "zipextimporter.pyo", line 82, in load_module File "wx\__init__.pyo", line 45, in ? File "zipextimporter.pyo", line 82, in load_module File "wx\_core.pyo", line 4, in ? File "zipextimporter.pyo", line 98, in load_module ImportError: MemoryLoadLibrary failed loading wx\_core_.pyd I get the same behaviour trying to build the sample file out of C:\Python24\Lib\site-packages\py2exe\samples\singlefile\gui I found this: http://article.gmane.org/gmane.comp.python.py2exe/1006 where Jimmy Retzlaff was responding to a similar question with a somewhat similar error dump. Jimmy provides a bare-bones wxPython application and a setup.py file there which seems to have solved the OP's problem, but I am seeing the same errors in even trying to do run those two simple files unmodified. So, being quite green with py2exe, I'm not sure where to turn next. (Those two files are copied at the end of this post for convenience - FYI, running the simple.py file directly, works fine on my system with wxPython installed.) I guess I am also unclear on the idea or terminology of building a single file executable. In setup.py in the ...\py2exe\samples\singlefile\gui dir, it has the following comments: # Requires wxPython. This sample demonstrates: # # - single file exe using wxPython as GUI. and options that imply things should all be bundled into a single file: setup( options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": 1, "bundle_files": 1}}, zipfile = None, windows = [test_wx], ) But when the build is run, there are several things in the dist directory, including msvcr71.dll. That is because of licensing issues with Microsoft? Are there other options to explicitly direct py2exe to link msvcr71.dll into the EXE? I found this article: http://www.devpicayune.com/entry/200701291417 which implies that the zipextimporter problem is actually stemming from a missing msvcp71.dll (notice that's 'p', not 'r'). I tried to resolve this by finding the DLL in the wxPython distribution (C:\Python24\Lib\site-packages\wx-2.8-msw-unicode\wx\msvcp71.dll) and manually copying it into the dist directory built by py2exe (next to msvcr71.dll), but that doesn't change the behavior (i.e., you still get an error and log file as above when running the exe). So... I'm not really sure what to try next. It's rather frustrating that the distributed examples don't seem to be working. Is this implying some sort of fundamental system incompatibility (wx version 2.8.0.1, Windows 2000 Professional, python 2.4.4, py2exe 0.6.6) or am I simply misunderstanding something? At this point I am more concerned with simplicity than efficiency. That is, I want a single executable I can distribute that has pretty much *everything* that would reasonably be required to execute my wxPython GUI on a Windows system, I understand and accept that the exe is going to be quite large. Working the tutorial found at: http://www.py2exe.org/index.cgi/Tutorial pretty much makes sense to me and produces a console executable that does what I would expect so, some things *are* working but I am running into problems where wx is involved. Changing the setup call in the tutorial to this: setup( options = { "py2exe" : { "ascii" : 1, "bundle_files" : 1, } }, console=["foo.py"], ) still leaves these files in the dist directory, so I'm not clear on exactly what they are or why they are not linked into the EXE if they are required. 02/01/2007 01:19p 15,872 foo.exe 02/01/2007 01:19p 2,191,370 library.zip 03/16/2006 03:19p 348,160 MSVCR71.dll 10/18/2006 08:18a 4,608 w9xpopen.exe I guess the first step would be to get the two files in Jimmy's post to work. Anyone else experiencing similar errors with those files? After that, the sample under .../singlefile/gui ought to work. Any general advice for a noobie and information about options to explicitly bundle DLL's and other files would be greatly appreciated. Links to other tutorials also appreciated. Sorry this is a bit long - thanks for taking the time to read my post. -ej Here's some basic information about my environment: OS: Windows 2000 Professional C:\Documents and Settings\ej\Desktop\src\dist_test>python Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import wx >>> wx <module 'wx' from 'C:\Python24\lib\site-packages\wx-2.8-msw-unicode\wx\__init__. pyc'> >>> wx.__version__ '2.8.0.1' >>> import py2exe >>> py2exe <module 'py2exe' from 'C:\Python24\lib\site-packages\py2exe\__init__.pyc'> >>> py2exe.__version__ '0.6.6' >>> And here's Jimmy's two files I said I would include: #======================================================================= 'simple.py' import wx class MyFrame(wx.Frame): def __init__(self, parent, title): wx.Frame.__init__(self, parent, -1, title, pos=(150, 150), size=(350, 200)) panel = wx.Panel(self) text = wx.StaticText(panel, -1, "Hello World!", (10, 10)) class MyApp(wx.App): def OnInit(self): MyFrame(None, "Simple").Show(True) return True app = MyApp(redirect=False) app.MainLoop() #======================================================================= 'setup.py' from distutils.core import setup import py2exe setup( script_args=['py2exe', '--bundle=1'], windows=["simple.py"], zipfile=None ) #======================================================================= |