I am using py2exe (version 0.6.6) along with Python 2.4 and wxPython 2.8. I was using wxPython 2.6 before.
I can run my application just fine from Wing IDE, but when I build it using py2exe, I get the following error
AttributeError: 'module' object has no attribute 'build'
This happens on the line of code:
from wx import *
One you should no longer use this type of import, change it to:
import wx
And make corresponding changes in your code (e.g. wxFrame becomes wx.Frame etc), if there is a lot of code you might want to look at Boa's 2.4 to 2.5/2.6 code converter - it converts a lot of the code but there are still some things you might have to do manually.
Allows when you change e.g. Python, or wxPython you should clear the dist folder of py2exe, I just include the following code in my setup.py.
# cleanup dist and build directory first (for new py2exe version)
if os.path.exists("dist/prog"):
shutil.rmtree("dist/prog")
if os.path.exists("dist/lib"):
shutil.rmtree("dist/lib")
if os.path.exists("build"):
shutil.rmtree("build")
Hope this helps
Werner
···
I have noticed that the module 'build' is relatively new, so maybe something is cached somewhere?
Any idears? Thanks!
- Aaron Rubin
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.17/661 - Release Date: 30/01/2007 23:30
I am using py2exe (version 0.6.6) along with Python 2.4 and wxPython 2.8. I was using wxPython 2.6 before.
I can run my application just fine from Wing IDE, but when I build it using py2exe, I get the following error
AttributeError: 'module' object has no attribute 'build'
This happens on the line of code:
from wx import *
I have noticed that the module 'build' is relatively new, so maybe something is cached somewhere?
Any idears? Thanks!
You have two choices:
1. Don't use "from wx import *" as has already been mentioned. It is trying to import everything in the wx.__all__ list even if you don't use it, and py2exe is not including those things that you don't use so it is not finding it in the bundled modules at runtime. By not doing an "import *" you will also save the memory needed to load about 3400 names/references into each of your modules' dictionaries.
2. Force py2exe to include the wx.build package, and anything else that it complains about after that.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!