gui2exe will not produce result after starting to use pubsub

91 views
Skip to first unread message

samuel en

unread,
Apr 12, 2010, 7:38:04 AM4/12/10
to wxPython-users
Hi, hoping this place is ok to ask a question about gui2exe
I used the really great gui2exe program to prepare python code for
distribution, and it just worked fine.
Till I started to use pubsub (after some tips on this forum): now the
exe will not run anymore.

I did the following "to archieve" the problem with the exe to run: 1)
install the pubsub stuff, 2) in two modules I wrote: from pubsub
import pub.
In WingIDE the code just runs just fine.
However the exe produced by Gui2Exe states (LOG FILE) states:
Traceback (most recent call last):
File "mainwin122.py", line 2, in <module>
File "pubsub\pub.pyc", line 27, in <module>
File "pubsub\core\pubsub3.pyc", line 21, in <module>
File "pubsub\core\listener.pyc", line 13, in <module>
ImportError: No module named listenerimpl
Traceback (most recent call last):
File "mainwin122.py", line 2, in <module>
File "pubsub\pub.pyc", line 27, in <module>
File "pubsub\core\pubsub3.pyc", line 21, in <module>
File "pubsub\core\listener.pyc", line 13, in <module>
ImportError: No module named listenerimpl
Traceback (most recent call last):
File "mainwin122.py", line 2, in <module>
File "pubsub\pub.pyc", line 27, in <module>
File "pubsub\core\pubsub3.pyc", line 21, in <module>
File "pubsub\core\listener.pyc", line 13, in <module>
ImportError: No module named listenerimpl
Traceback (most recent call last):
File "mainwin122.py", line 2, in <module>
File "pubsub\pub.pyc", line 27, in <module>
File "pubsub\core\pubsub3.pyc", line 21, in <module>
File "pubsub\core\listener.pyc", line 13, in <module>
ImportError: No module named listenerimpl

Unfamiliar with the interface of gui2exe as I am I included all *.pyc
files in the "python module" fields in gui2exe (3 entries). Now
gui2exe will not produce an exe but creates a long list of errors,
first being ctypes_com_server etc.
And from full build output dialog:
running py2exe
creating E:\___python.excel\mainwin\build
creating E:\___python.excel\mainwin\build\bdist.win32
creating E:\___python.excel\mainwin\build\bdist.win32\winexe
creating E:\___python.excel\mainwin\build\bdist.win32\winexe
\collect-2.6
creating E:\___python.excel\mainwin\build\bdist.win32\winexe
\bundle-2.6
creating E:\___python.excel\mainwin\build\bdist.win32\winexe\temp
*** searching for required modules ***
C:\Python26\lib\site-packages\py2exe\build_exe.py:16:
DeprecationWarning: the sets module is deprecated
import sets
Traceback (most recent call last):
File "E:\___python.excel\mainwin\tmpb0rqrx.py", line 106, in
<module>
ctypes_com_server = []
File "C:\Python26\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python26\lib\distutils\dist.py", line 975, in run_commands
self.run_command(cmd)
File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
cmd_obj.run()
File "C:\Python26\lib\site-packages\py2exe\build_exe.py", line 243,
in run
self._run()
File "C:\Python26\lib\site-packages\py2exe\build_exe.py", line 296,
in _run
self.find_needed_modules(mf, required_files, required_modules)
File "C:\Python26\lib\site-packages\py2exe\build_exe.py", line 1297,
in find_needed_modules
mf.import_hook(mod)
File "C:\Python26\lib\site-packages\py2exe\mf.py", line 719, in
import_hook
return Base.import_hook(self,name,caller,fromlist,level)
File "C:\Python26\lib\site-packages\py2exe\mf.py", line 136, in
import_hook
q, tail = self.find_head_package(parent, name)
File "C:\Python26\lib\site-packages\py2exe\mf.py", line 204, in
find_head_package
raise ImportError, "No module named " + qname
ImportError: No module named C:\Python26\Lib\site-packages\pubsub\pub


So what should I do?
Are there option to get gui2exe working with pubsub or should I just
remove the pubsub code, waiting for the next release. For sure I don't
want to stop using gui2exe, because although the hint over windows are
really annoying and disfunctional, the rest of the program is just
superb!!

Tia Samuel

Andrea Gavana

unread,
Apr 12, 2010, 7:46:00 AM4/12/10
to wxpytho...@googlegroups.com
Hi,

On 12 April 2010 12:38, samuel en wrote:
> Hi, hoping this place is ok to ask a question about gui2exe
> I used the really great gui2exe program to prepare python code for
> distribution, and it just worked fine.

You should use the GUI2Exe group on googlegroups:

http://groups.google.com/group/gui2exe

But anyway, this should be an easy one.

Don't do that. If pubsub is a package (i.e., has a directory structure
and/or an __init__.py module for it), just add it to the proper list
control in GUI2Exe (packages). Otherwise, it is a module and you
should add the pubsub.py file alone (or whatever its name is).

> So what should I do?
> Are there option to get gui2exe working with pubsub or should I just
> remove the pubsub code, waiting for the next release. For sure I don't
> want to stop using gui2exe, because although the hint over windows are
> really annoying and disfunctional, the rest of the program is just
> superb!!

You can remove the "hint over windows" (i.e., tooltips) using the menu
"Options" => "Show tooltips" and GUI2Exe will not bugger you anymore.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

==> Never *EVER* use RemovalGroup for your house removal. You'll
regret it forever.
http://thedoomedcity.blogspot.com/2010/03/removal-group-nightmare.html <==

samuel en

unread,
Apr 12, 2010, 8:06:10 AM4/12/10
to wxPython-users
Hi Andrea

> You should use the GUI2Exe group on googlegroups:

Ok, in future I will do so, but since you are reading this group
now:


> But anyway, this should be an easy one.

"Don't do that. If pubsub is a package (i.e., has a directory


structure
and/or an __init__.py module for it), just add it to the proper list
control in GUI2Exe (packages). Otherwise, it is a module and you
should add the pubsub.py file alone (or whatever its name is). "

I am not sure how to do this, I tried adding c:\py......\site.....
\pubsub to packages: still ctypes_con_server=[] error, and before I
tried to add it to the modules (see before).

Please some more hints (I am a newbie).


>You can remove the "hint over windows" (i.e., tooltips) using the menu
>"Options" => "Show tooltips" and GUI2Exe will not bugger you anymore.

In your defense, a lot of programs, including M$soft ones have
problems leaving the screen clean after showing a tooltip. Your tool
tips are behaving more or less accordingly, maybe with a little more
"noise". But they look really cool.


Tia, Samuel

Andrea Gavana

unread,
Apr 12, 2010, 8:12:49 AM4/12/10
to wxpytho...@googlegroups.com
Hi Samuel,

On 12 April 2010 13:06, samuel en wrote:
> Hi Andrea
>
>> You should use the GUI2Exe group on googlegroups:
>
> Ok, in future I will do so, but since  you are reading this group
> now:
>> But anyway, this should be an easy one.
>
> "Don't do that. If pubsub is a package (i.e., has a directory
> structure
> and/or an __init__.py module for it), just add it to the proper list
> control in GUI2Exe (packages). Otherwise, it is a module and you
> should add the pubsub.py file alone (or whatever its name is). "
>
> I am not sure how to do this, I tried adding c:\py......\site.....
> \pubsub to packages: still ctypes_con_server=[] error, and before I
> tried to add it to the modules (see before).
>
> Please some more hints (I am a newbie).

OK, when you want to insert a module (in the Includes list) or a
package (in the Packages list), GUI2Exe (and py2exe) only asks for the
module or package *name*, not the full path. So, what you should do
is:

1) Go to the "Packages" list control and click the small green "plus"
button at the bottom right of the list control, or right-click inside
the list control and choose "Add Item(s)";
2) Edit the item that has magically appeared (it is called "==> Edit
Me! <==" as a hint) by clicking on it: just enter the package name you
want to include (in this case, I believe it is "pubsub" but it may
also be "pypubsub", I have no idea, I have never used it);
3) Save the project;
4) Re-run the compilation process.

It should go smoothly... if not, please post a traceback or a
screenshot of what happened in GUI2Exe.

samuel en

unread,
Apr 12, 2010, 8:51:32 AM4/12/10
to wxPython-users
Hi,

Well, I am having still problems. Probably it is with the name
resolution or I am blind (this happens sometimes).
One would expect that the names to be inserted into GUI2EXE would not
be to hard to combine logically wise with the name of the modules as
used in python code.
E.g. in code I use "from pubsub import pub", so I would expect
something like "pubsub", "pubsub.py" maybe with a full path like "C:
\PYTHON26\\....." as a prefix. No.
Otherwise, modules/packages like numpy work without any problems, so
it looks like the problem is specific to pubsub.

To show what I have included, which ran without any problems:

[from the main module]:
import gradientB001 as gr
from pubsub import pub <----------------the one and
only error
import gradient, icons, circleGauge
import chooser, verbchooser
import cPickle,time
import wx, wx.grid, wx.html, wx.aui
import colorsys, sys, time, os, random
import icon
from math import cos, sin, radians
import cStringIO
import wx.lib.agw.aui as aui
from wx.lib.agw.aui import aui_switcherdialog as ASD

So I am finding myself not knowing what to do, except removing pubsub
and replacing this by other code.


Ciao, Samuel

Andrea Gavana

unread,
Apr 12, 2010, 8:58:49 AM4/12/10
to wxpytho...@googlegroups.com
Hi Samuel,

I am not sure what's wrong with pubsub, I know there are other people
using it with GUI2Exe/py2exe without much hassle. Can you share your
setup.py file generated by GUI2Exe (menu "File" => "Export setup
file") or a screenshot of your GUI2Exe setup? It would be better to
see a setup file as that will give us an opportunity to spot any error
better.

samuel en

unread,
Apr 12, 2010, 9:38:19 AM4/12/10
to wxPython-users
Hi,

Yeah, I at a total loss here.

Anyway the Export setup file yields this (I don't know how to keep the
correct indentation):

# ======================================================== #
# File automagically generated by GUI2Exe version 0.5.0
# Copyright: (c) 2007-2009 Andrea Gavana
# ======================================================== #

# Let's start with some default (for me) imports...

from distutils.core import setup
from py2exe.build_exe import py2exe

import glob
import os
import zlib
import shutil

# Remove the build folder
shutil.rmtree("build", ignore_errors=True)


class Target(object):
""" A simple class that holds information on our executable file.
"""
def __init__(self, **kw):
""" Default class constructor. Update as you need. """
self.__dict__.update(kw)


# Ok, let's explain why I am doing that.
# Often, data_files, excludes and dll_excludes (but also resources)
# can be very long list of things, and this will clutter too much
# the setup call at the end of this file. So, I put all the big lists
# here and I wrap them using the textwrap module.

data_files = []

includes = []
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email',
'pywin.debugger',
'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
'Tkconstants', 'Tkinter']
packages = []
dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll',
'tcl84.dll',
'tk84.dll']
icon_resources = []
bitmap_resources = []
other_resources = []


# This is a place where the user custom code may go. You can do almost
# whatever you want, even modify the data_files, includes and friends
# here as long as they have the same variable name that the setup call
# below is expecting.

# No custom code added


# Ok, now we are going to build our target class.
# I chose this building strategy as it works perfectly for me :-D

GUI2Exe_Target_1 = Target(
# what to build
script = "mainwin122.py",
icon_resources = icon_resources,
bitmap_resources = bitmap_resources,
other_resources = other_resources,
dest_base = "mainwin122",
version = "0.1",
company_name = "No Company",
copyright = "No Copyrights",
name = "Py2Exe Sample File",

)

# No custom class for UPX compression or Inno Setup script

# That's serious now: we have all (or almost all) the options py2exe
# supports. I put them all even if some of them are usually defaulted
# and not used. Some of them I didn't even know about.

setup(

# No UPX or Inno Setup

data_files = data_files,

options = {"py2exe": {"compressed": 0,
"optimize": 0,
"includes": includes,
"excludes": excludes,
"packages": packages,
"dll_excludes": dll_excludes,
"bundle_files": 3,
"dist_dir": "dist",
"xref": False,
"skip_archive": False,
"ascii": False,
"custom_boot_script": '',
}
},

zipfile = None,
console = [],
windows = [GUI2Exe_Target_1],
service = [],
com_server = [],
ctypes_com_server = []
)

# This is a place where any post-compile code may go.
# You can add as much code as you want, which can be used, for
example,
# to clean up your folders or to do some particular post-compilation
# actions.

# No post-compilation code added


# And we are done. That's a setup script :-D

Andrea Gavana

unread,
Apr 12, 2010, 9:45:02 AM4/12/10
to wxpytho...@googlegroups.com
Hi,

^^^^^^^^^^^^^^^^^^^^^^

You haven't included pubsub as a package as I suggested in a previous message.
As it stands, it seems a very normal and simple setup.py file (except
for all the bull**** GUI2Exe comments in it :-D ), and I can't see
anything wrong with it.

samuel en

unread,
Apr 12, 2010, 9:55:36 AM4/12/10
to wxPython-users
Hi,

I did read your previous message, but maybe I missed something.

"You haven't included pubsub as a package as I suggested in a previous
message.
As it stands, it seems a very normal and simple setup.py file (except
for all the bull**** GUI2Exe comments in it :-D ), and I can't see
anything wrong with it."

I am sorry, but I needed to generate the setup and I forget to include
the C:\Python26\Lib\site-packages\pubsub\
or C:\Python26\Lib\site-packages\pubsub (not the missing of the
trailing \). I thought you just needed the setupfile.
Anyway this is the file:

data_files = []

packages = ['C:\\Python26\\Lib\\site-packages\\pubsub\\']

)

setup(

data_files = data_files,


I really appreciate your help. It would be great to get the exe
running again.

Ciao Samuel

Mike Driscoll

unread,
Apr 12, 2010, 11:34:17 AM4/12/10
to wxpytho...@googlegroups.com
On Mon, Apr 12, 2010 at 8:55 AM, samuel en <samuel...@gmail.com> wrote:
Hi,

I did read your previous message, but maybe I missed something.

"You haven't included pubsub as a package as I suggested in a previous
message.
As it stands, it seems a very normal and simple setup.py file (except
for all the bull**** GUI2Exe comments in it :-D ), and I can't see
anything wrong with it."

I am sorry, but I needed to generate the setup and I forget to include
the C:\Python26\Lib\site-packages\pubsub\
or C:\Python26\Lib\site-packages\pubsub (not the missing of the
trailing \). I thought you just needed the setupfile.
Anyway this is the file:


<snipped>

 

I really appreciate your help. It would be great to get the exe
running again.

Ciao Samuel




This is really weird. I don't have to specifically include pubsub. However, I've included a screenshot to illustrate what Andrea's talking about. See where I have included the "sqlalchemy" package. Just add your package there. It's possible you'll need to include it as "wx.lib.pubsub" instead of "pubsub", but I don't really know for sure. Make sure you have the latest GUI2Exe by downloading the source.


--
-----------------
Mike Driscoll

Blog:   http://blog.pythonlibrary.org
gui2exe.jpg

Robin Dunn

unread,
Apr 12, 2010, 3:28:38 PM4/12/10
to wxpytho...@googlegroups.com
On 4/12/10 8:34 AM, Mike Driscoll wrote:
>
> This is really weird. I don't have to specifically include pubsub.

Have you tried it with the new pubsub package, or just the current
pubsub module in the wx.lib? The new package does some dynamic imports
and so that may be what is confusing py2exe.

http://pubsub.sourceforge.net/

--
Robin Dunn
Software Craftsman
http://wxPython.org

samuel en

unread,
Apr 13, 2010, 3:38:59 AM4/13/10
to wxPython-users
Hi, thanks for the great help. Problem solved with wx.lib version of
pubsub.

>>>It's possible you'll need to include it as "wx.lib.pubsub" instead of
>>>"pubsub", but I don't really know for sure.

Unaware there was a pubsub in wxlib, II was using pubsub from
http://pubsub.sourceforge.net/.

The import line was: from pubsub import pub
I changed this to: from wx.lib.pubsub import Publisher and obviously
in the code pub.* to Publisher.*. Then I needed to change the
seemingly new style with arg1=... arg2=... like:
Publisher.sendMessage('rootTopic', arg1=123, arg2=dict(a='abc',
b='def'))
to the old (?) pubsub style like: Publisher.sendMessage('rootTopic',
"test").

And all problems are gone (using gui2exe 0.5.0, without including
anything explicitly).

>>>The new package does some dynamic imports
>>>and so that may be what is confusing py2exe

Yes, the first error message I was getting was: ImportError: No
module named listenerimpl.
listenerimp.py lives in subdir arg1 of core of pubsub and is
dynamically called (so says the __init file there). If I copy all the
files from subdir arg1 to core and delete arg1 and change some code in
the import sections, like in listener.py and import all the .py in
core in pubsub.py: The exe runs after building it with GUI2EXE (but I
got other errors , like arg1 style argumentpassing stopped working).
Too complicated for me to figure this out, but he I am happy with the
old style pubsub.

Anyway, problem solved, thanks guys!
Samuel

shollie

unread,
Apr 13, 2010, 4:11:15 PM4/13/10
to wxPython-users
This is a problem with py2exe, not gui2exe or pubsub. It happens to
any package that manipulates the __path__ of a module (such as done by
pywin32), and pubsub uses this (well documented, albeit rarely needed)
technique. It looks like there is a solution (involving modulefinder
from the std lib) but I'm still searching for the best way to address
this and tell py2exe how to find the missing info. If anyone knows
please post.
Oliver

shollie

unread,
Apr 14, 2010, 2:17:43 AM4/14/10
to wxPython-users
I did a fair bit of searching around on the web. There is definitely
no problem with pubsub, instead a limitation in py2exe: it does not
handle runtime mods to __path__ variables, which several packages like
win32com and a few others (like pubsub!) use. Posts about py2exe
problems for such packages mention something about having to use
modulefinder (in Python standard lib) but I found it was not
necessary: simply adding an item 'pubsub', as Andrea first suggested,
to the Packages list, worked perfectly. This resulted in the setup.py
with the line

packages = ['pubsub']

so it is just the package name, no folder etc.

I don't know enough about py2exe to understand why when pubsub is not
explicitely mentioned, some of its modules are not found. Possibly,
items in "packages" list are explicitely imported by setup.py, in
which case the __path__ does get set properly; otherwise py2exe just
loads .py files through AST and finds import statements (I read that
py2exe doesn't handle conditional imports... again, likely just adding
such package to Packages would fix this).

HTH,
Oliver

scholli

unread,
Apr 14, 2010, 2:41:02 AM4/14/10
to wxPython-users
Samuel, there is no issue with pubsub AFAICT (see my other recent
posts in this thread), so you are just delaying the issue because
Robin is planning on upgrading wx.lib.pubsub to the most recent pubsub
(from pubsub.sf.net), which is the one you were using in the first
place :>

Try again with adding a 'pubsub' entry in Packages list, let us know
how that goes (the only list that Andrea and I are *both* on is this
one -- wxpython-users -- so it may be best to keep this thread here
rather than on gui2exe or pubsub-users, if others are ok with that).

Oliver

samuel en

unread,
Apr 14, 2010, 10:26:08 AM4/14/10
to wxPython-users
Hi everyone,
I am sorry but I deleted my original source files by mistake.
Maybe someone else can do the testing of the formentioned problem.

Samuel.

Steven Sproat

unread,
Apr 14, 2010, 11:29:10 AM4/14/10
to wxpytho...@googlegroups.com
> --
> To unsubscribe, send email to wxPython-user...@googlegroups.com
> or visit http://groups.google.com/group/wxPython-users?hl=en
>
> To unsubscribe, reply using "remove me" as the subject.
>

A friendly suggestion: use a version control system. Doesn't even have
to be used online, if you use Bazaar then you can commit locally.

Pacific Morrowind

unread,
Apr 14, 2010, 12:58:18 PM4/14/10
to wxpytho...@googlegroups.com
On 14/04/2010 8:29 AM, Steven Sproat wrote:
>
> A friendly suggestion: use a version control system. Doesn't even have
> to be used online, if you use Bazaar then you can commit locally.
>
>
Git can also do that (my preferred versioning system) - and if you the
want to move online it is very easy to do as well. (don't know anything
about Bazaar so don't know whether you can do that easily with Bazaar as
well)
Pacific

samuel en

unread,
Apr 15, 2010, 5:16:09 AM4/15/10
to wxPython-users
Hi, sorry for the delay and thanks for all the help.
Just entering >a 'pubsub' entry in Packages list WORKS!!.
I must have had a big blind spot.

Thanks, Samuel

Reply all
Reply to author
Forward
0 new messages