[Pythonmac-SIG] py2app wx.lib.pubsub.Publisher problem

Hyeonseung I tifereth at gmail.com
Sat Sep 17 05:37:43 CEST 2011


Hi,

I`m trying to make an app bundle via py2app from a project using wxPython and it`s pub feature.
But there is a problem whenever running the app.

In my code, Publisher is imported as:
from wx.lib.pubsub import Publisher as pub

and use:
pub.subscribe(self.OnImageUpdated, 'image.updated')

But when I run the app, error message is in a console:
ImportError: cannot import name Publisher

I`ve tested many time with various method.

Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 14:13:39) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> wx.version()
'2.8.12.0 (mac-unicode)'
>>> import wx.lib.pubsub as ppp
>>> ppp
<module 'wx.lib.pubsub' from '/usr/local/lib/wxPython-unicode-2.8.12.0/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/lib/pubsub/__init__.pyc'>
>>> ppp.Publisher
<wx.lib.pubsub.pub.PublisherClass instance at 0x1401a3f0>
>>> 

Publisher is an instance of wx.lib.pubsub.pub.PublisherClass
In other word, Publisher is NOT a module.
But in the app bundle, python try to regard 'Publisher' as module. WHY?

So, I tried to change my code:
import wx.lib.pubsub as ppp
pub = ppp.Publisher
......
pub.subscribe(self.OnImageUpdated, 'image.updated')
.....

In this case, error massage is like this:
AttributeError: 'module' object has no attribute 'Publisher'

What`s the problem? 



More information about the Pythonmac-SIG mailing list