简体   繁体   中英

AttributeError: 'module' object has no attribute 'subscribe' Python

I'm Using Kubuntu 13.10 64 bit and Python 2.7.5+ and wxPython 2.8.12.1 . I'm trying to use the wx.lib.pubsub module to update wx.Gauge from different class (thread class). I have in my code such imports:

try:
    from pubsub import pub
except ImportError:
    from wx.lib.pubsub import pub

but when I start my application, I'm getting the error:

    pub.subscribe(self.updateProgress, "update")
AttributeError: 'module' object has no attribute 'subscribe'

What's wrong and how to fix it?

wxPython 2.8.12 contains an older version of pubsub.

In your code it is not clear which version you error on, in other words which import worked? I guess it is the one from wx.lib which with 2.8.12 would be the old version of pubsub.

I would suggest to use either a newer version of wxPython, eg 3.0.2 or use the stand alone pypubsub, but if you want to stick with 2.8 then the doc shows you what needs to be done. http://pubsub.sourceforge.net/usage/howtos/upgrade_v1tov3.html#label-upgrade-for-wx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM