Reputation: 4946
I successfully created a .exe from my .py using py2exe. But when I try to run the app from the exe I get this error message:
Traceback (most recent call last):
File "StreetSoccer.py", line 13, in <module>
ImportError: cannot import name Publisher
I alredy found this page: ImportError: cannot import name Publisher but I'm using python2.7. Here is the line of my .py where I import Publisher:
from wx.lib.pubsub import Publisher
Hope you can help me.
Edit: I made these changes:
# from wx.lib.pubsub import Publisher
from wx.lib.pubsub import setupv1
from wx.lib.pubsub import pub
Publisher = pub.Publisher()
And now I get this error message (after py2exe):
File "StreetSoccer.py", line 14, in <module>
File "wx\lib\pubsub\setupv1.pyc", line 16, in setVersion
File "wx\lib\pubsub\pubsubconf.pyc", line 16, in setVersion
File "wx\lib\pubsub\pubsubconf.pyc", line 70, in setVersion
File "wx\lib\pubsub\pubsubconf.pyc", line 78, in __setupForV1
File "wx\lib\pubsub\pub.pyc", line 24, in <module>
File "wx\lib\pubsub\core\listener.pyc", line 13, in <module>
Import Error: No module named listenerimpl
Upvotes: 0
Views: 2345
Reputation: 12138
py2exe does not include all packages you use, like in this case the packages related to pubsub. Use a setup.py
that tells py2exe about the relevant pubsub packages:
setup(
data_files=data_files,
windows=[{'script': 'StreetSoccer.py'}],
options=[{'includes': ["wx.lib.pubsub.*", "wx.lib.pubsub.core.*",
"wx.lib.pubsub.core.kwargs.*"]}]
)
See also: ImportError: cannot import name Publisher
Upvotes: 1