I had to recompile some changes in one of my new applications today
and the resulting binary wouldn't run because it couldn't import
Pubsub. Since all I had added was a conditional, I knew it had to be
because I had upgraded to 2.8.11.0. The import call looks like this:
from wx.lib.pubsub import Publisher
The code runs fine from source, but when I try to build a binary using
GUI2Exe / py2exe, the result doesn't work. It immediately crashes with
a "cannot import Publisher" error.
I tried to add Publisher as a module or a package, but I can't seem to
find the right way to do it yet. Does anyone have any ideas?
Forgot to mention this, but I'm on Windows XP, Python 2.5.4
Thanks!
···
On Jun 14, 10:24 am, Mike Driscoll <kyoso...@gmail.com> wrote:
Hi,
I had to recompile some changes in one of my new applications today
and the resulting binary wouldn't run because it couldn't import
Pubsub. Since all I had added was a conditional, I knew it had to be
because I had upgraded to 2.8.11.0. The import call looks like this:
from wx.lib.pubsub import Publisher
The code runs fine from source, but when I try to build a binary using
GUI2Exe / py2exe, the result doesn't work. It immediately crashes with
a "cannot import Publisher" error.
I tried to add Publisher as a module or a package, but I can't seem to
find the right way to do it yet. Does anyone have any ideas?
On Mon, Jun 14, 2010 at 10:25 AM, Mike Driscoll <kyosohma@gmail.com> wrote:
On Jun 14, 10:24 am, Mike Driscoll <kyoso...@gmail.com> wrote:
Hi,
I had to recompile some changes in one of my new applications today
and the resulting binary wouldn't run because it couldn't import
Pubsub. Since all I had added was a conditional, I knew it had to be
because I had upgraded to 2.8.11.0. The import call looks like this:
from wx.lib.pubsub import Publisher
The code runs fine from source, but when I try to build a binary using
GUI2Exe / py2exe, the result doesn't work. It immediately crashes with
a "cannot import Publisher" error.
I tried to add Publisher as a module or a package, but I can't seem to
find the right way to do it yet. Does anyone have any ideas?
The new Pubsub in 2.8.11 is no longer a stand alone module, its a
package of a number of modules. I haven't looked at it in detail yet
so this is just a guess, but you probably will need to add something
like the following to your setup.py's includes.
I was aware that Pubsub had been upgraded to the new API. I didn't
know I could use wildcards in my includes line though. I just tried
that, but I get the same error. I'll keep messing with it.
- Mike
···
On Jun 14, 10:31 am, Cody Precord <codyprec...@gmail.com> wrote:
Hi,
On Mon, Jun 14, 2010 at 10:25 AM, Mike Driscoll <kyoso...@gmail.com> wrote:
> On Jun 14, 10:24 am, Mike Driscoll <kyoso...@gmail.com> wrote:
>> Hi,
>> I had to recompile some changes in one of my new applications today
>> and the resulting binary wouldn't run because it couldn't import
>> Pubsub. Since all I had added was a conditional, I knew it had to be
>> because I had upgraded to 2.8.11.0. The import call looks like this:
>> from wx.lib.pubsub import Publisher
>> The code runs fine from source, but when I try to build a binary using
>> GUI2Exe / py2exe, the result doesn't work. It immediately crashes with
>> a "cannot import Publisher" error.
>> I tried to add Publisher as a module or a package, but I can't seem to
>> find the right way to do it yet. Does anyone have any ideas?
The new Pubsub in 2.8.11 is no longer a stand alone module, its a
package of a number of modules. I haven't looked at it in detail yet
so this is just a guess, but you probably will need to add something
like the following to your setup.py's includes.
I had to recompile some changes in one of my new applications today
and the resulting binary wouldn't run because it couldn't import
Pubsub. Since all I had added was a conditional, I knew it had to be
because I had upgraded to 2.8.11.0. The import call looks like this:
from wx.lib.pubsub import Publisher
The code runs fine from source, but when I try to build a binary using
GUI2Exe / py2exe, the result doesn't work. It immediately crashes with
a "cannot import Publisher" error.
I tried to add Publisher as a module or a package, but I can't seem to
find the right way to do it yet. Does anyone have any ideas?
Thanks!
- Mike
Forgot to mention this, but I'm on Windows XP, Python 2.5.4
I see the same on Win 7 and Py 2.6.5 when I just added the above import to the sample wx app on the wiki page for py2exe.
Looking a bit into it it looks like the forcing to version one does not work when frozen, see pubsub.__init__.py line 66 and 67, also autosetuppubsubv1.pyo is present in the library.zip.
To work around I did this:
from wx.lib.pubsub import setupv1 as psv1
from wx.lib.pubsub import Publisher
And in the setup.py this:
packages = ['wx.lib.pubsub']
Hope this helps
Werner
···
On 14/06/2010 17:25, Mike Driscoll wrote:
On Jun 14, 10:24 am, Mike Driscoll<kyoso...@gmail.com> wrote:
So I don't think its quite using the old API there. I don't know the
new API at the moment, but I guess I should just figure it out...
Thanks for the help though!
···
On Jun 14, 11:03 am, werner <wbru...@free.fr> wrote:
Hi Mike,
On 14/06/2010 17:25, Mike Driscoll wrote:
> On Jun 14, 10:24 am, Mike Driscoll<kyoso...@gmail.com> wrote:
>> Hi,
>> I had to recompile some changes in one of my new applications today
>> and the resulting binary wouldn't run because it couldn't import
>> Pubsub. Since all I had added was a conditional, I knew it had to be
>> because I had upgraded to 2.8.11.0. The import call looks like this:
>> from wx.lib.pubsub import Publisher
>> The code runs fine from source, but when I try to build a binary using
>> GUI2Exe / py2exe, the result doesn't work. It immediately crashes with
>> a "cannot import Publisher" error.
>> I tried to add Publisher as a module or a package, but I can't seem to
>> find the right way to do it yet. Does anyone have any ideas?
>> Thanks!
>> - Mike
> Forgot to mention this, but I'm on Windows XP, Python 2.5.4
I see the same on Win 7 and Py 2.6.5 when I just added the above import
to the sample wx app on the wiki page for py2exe.
Looking a bit into it it looks like the forcing to version one does not
work when frozen, see pubsub.__init__.py line 66 and 67, also
autosetuppubsubv1.pyo is present in the library.zip.
To work around I did this:
from wx.lib.pubsub import setupv1 as psv1
from wx.lib.pubsub import Publisher
And in the setup.py this:
packages = ['wx.lib.pubsub']
There is some dynamic path issue in this module to mantain
compatibility with older
version 1 and 2 of the module.
After some trial and error i decided to swap to PyDispatcher PyDispatcher · PyPI.
I've found this module quite similar for basic pubsub
and it runs with py2exe.
There is also to consider that if you want to use the new 3.0 pubsub
interface you have to change your code.
Bye
···
On 14 Giu, 17:24, Mike Driscoll <kyoso...@gmail.com> wrote:
Hi,
I had to recompile some changes in one of my new applications today
and the resulting binary wouldn't run because it couldn't import
Pubsub. Since all I had added was a conditional, I knew it had to be
because I had upgraded to 2.8.11.0. The import call looks like this:
from wx.lib.pubsub import Publisher
The code runs fine from source, but when I try to build a binary using
GUI2Exe / py2exe, the result doesn't work. It immediately crashes with
a "cannot import Publisher" error.
I tried to add Publisher as a module or a package, but I can't seem to
find the right way to do it yet. Does anyone have any ideas?
This was discussed not long ago in another thread on this list and it was a simple matter of adding the extra setup attribute for package. I haven’t looked at how the use of autopubusbv1 changes this, but the solution of implicitely importing setupv1 should take care of any gotchas (if there are any – there is no reason there would be).
Note that the error message indicates that you are in fact NOT using the version 1 API. The setupv1 (automatically imported for you if autopubsubv1 is found) is exacty the old API (in fact, it’s even the same module file put inside the package, with some special import handling for now).
I’ll try to look more closely later, if you any of you make any progress please post.
Oliver
···
On Mon, Jun 14, 2010 at 12:13 PM, Mike Driscoll kyosohma@gmail.com wrote:
So I'm using the new API and didn't even know it? I'm pretty sure I
was basing my code on old examples, and I think I've been using this
code since at least wx 2.8.9.x so I don't know how this works...
I've tried it with
from wx.lib.pubsub import setupv2
from wx.lib.pubsub import Publisher
The above doesn't work at all from source (probably for some obvious
reason). The following doesn't work when frozen:
from wx.lib.pubsub import Publisher
or
from wx.lib.pubsub import setupv1
from wx.lib.pubsub import Publisher
The solution is simple! Downgrade to 2.8.10.1. I guess I need to
figure out whatever the new accepted way is and just do it that way...
···
On Jun 14, 11:59 am, oliver <oliver.schoenb...@gmail.com> wrote:
This was discussed not long ago in another thread on this list and it was a
simple matter of adding the extra setup attribute for package. I haven't
looked at how the use of autopubusbv1 changes this, but the solution of
implicitely importing setupv1 should take care of any gotchas (if there are
any -- there is no reason there would be).
Note that the error message indicates that you are in fact NOT using the
version 1 API. The setupv1 (automatically imported for you if autopubsubv1
is found) is *exacty* the old API (in fact, it's even the same module file
put inside the package, with some special import handling for now).
I'll try to look more closely later, if you any of you make any progress
please post.
Oliver
Forcing to v1 doesn't work when frozen, haven't figured out how to fix it yet.
I am doing this:
import sys
stdoutlog = file('py2test.log', 'a+')
sys.stdout = stdoutlog
sys.stderr = stdoutlog
import wx.lib.pubsub.setupv1
from wx.lib.pubsub import pub
print pub.VERSION_STR
Unfrozen I get:
1.1.200904.r159
Frozen I get:
3.1.1b1.201005.r243
Traceback (most recent call last):
File "simplewx.py", line 109, in <module>
File "simplewx.py", line 19, in create
File "simplewx.py", line 95, in __init__
TypeError: unbound method subscribe() must be called with PublisherKwargs instance as first argument (got instancemethod instance instead)
Will try and look into this some more later today or tomorrow afternoon.
Werner
···
On 14/06/2010 18:59, oliver wrote:
This was discussed not long ago in another thread on this list and it was a simple matter of adding the extra setup attribute for package. I haven't looked at how the use of autopubusbv1 changes this, but the solution of implicitely importing setupv1 should take care of any gotchas (if there are any -- there is no reason there would be).
Note that the error message indicates that you are in fact NOT using the version 1 API. The setupv1 (automatically imported for you if autopubsubv1 is found) is *exacty* the old API (in fact, it's even the same module file put inside the package, with some special import handling for now).
I'll try to look more closely later, if you any of you make any progress please post.
Oliver
So the py2exe freezing problem occurs only when using the legacy API. Two problems:
the “imp” module from Python core library does not seem to work within zip files, so autosetuppubsubv1 is not found, eventhough it is in the .zip created by py2exe. Solution (hack): import setupv1 explicitly in your application’s startup module.
legacy API setup requires the wx/lib/pubsub/pubsub1 folder, which for a reason that I don’t yet understand, py2exe does not copy into the library.zip. Solution (another hack): put an empty init.py in that folder.
The much preferable alternative (ie no hacks!) if you can hack it (sorry!) is to use the same messaging protocol as v1 but in latest API, this is called “arg1”:
from wx.lib.pubsub import setuparg1 # only in app’s startup module
from wx.lib.pubsub import pub as Publisher # in all modules that use pubsub
and replace any occurence of “Publisher().” by “Publisher.”
Oliver
···
On Mon, Jun 14, 2010 at 1:21 PM, Mike Driscoll kyosohma@gmail.com wrote:
Could you add this info to the wxPyWiki wherever it would be appropriate? (On the pusub related pages and/or the py2exe pages, or perhaps a new page linked to from those.) It would also be nice if you could review the current pubsub pages and update them if needed.
Thanks.
···
On 6/14/10 8:18 PM, oliver wrote:
So the py2exe freezing problem occurs only when using the legacy
API. Two problems:
1. the "imp" module from Python core library does not seem to work
within zip files, so autosetuppubsubv1 is not found, eventhough it
is in the .zip created by py2exe. Solution (hack): import
setupv1 explicitly in your application's startup module.
2. legacy API setup requires the wx/lib/pubsub/pubsub1 folder, which
for a reason that I don't yet understand, py2exe does not copy
into the library.zip. Solution (another hack): put an empty
__init__.py in that folder.
The much preferable alternative (ie no hacks!) if you can hack it
(sorry!) is to use the same messaging protocol as v1 but in latest API,
this is called "arg1":
from wx.lib.pubsub import setuparg1 # only in app's startup
module
from wx.lib.pubsub import pub as Publisher # in all modules that use pubsub
and replace any occurence of "Publisher()." by "Publisher."
Could you add this info to the wxPyWiki wherever it would be appropriate? (On the pusub related pages and/or the py2exe pages, or perhaps a new page linked to from those.) It would also be nice if you could review the current pubsub pages and update them if needed.
Thanks.
The docs are being updated, should make it onto the pubsub site pretty soon. As to py2exe, it is sufficiently popular that I’m thinking of just fixing as per above so it works when py2exe’d (no promises though).
So the py2exe freezing problem occurs only when using the legacy API. Two
problems:
1. the "imp" module from Python core library does not seem to work within
zip files, so autosetuppubsubv1 is not found, eventhough it is in the .zip
created by py2exe. Solution (hack): import setupv1 explicitly in your
application's startup module.
2. legacy API setup requires the wx/lib/pubsub/pubsub1 folder, which for
a reason that I don't yet understand, py2exe does not copy into the
library.zip. Solution (another hack): put an empty __init__.py in that
folder.
The much preferable alternative (ie no hacks!) if you can hack it (sorry!)
is to use the same messaging protocol as v1 but in latest API, this is
called "arg1":
from wx.lib.pubsub import setuparg1 # only in app's startup
module
from wx.lib.pubsub import pub as Publisher # in all modules that use pubsub
and replace any occurence of "Publisher()." by "Publisher."
Oliver
I just tried this and while it runs OK, when I run it through py2exe,
I get the following traceback:
Traceback (most recent call last):
File "PyTimesheet.py", line 36, in <module>
File "wx\lib\pubsub\pub.pyo", line 24, in <module>
File "wx\lib\pubsub\core\listener.pyo", line 13, in <module>
ImportError: No module named listenerimpl
···
On Jun 14, 10:18 pm, oliver <oliver.schoenb...@gmail.com> wrote:
Mike I don’t know what else to say: as mentioned, it works flawlessly on my machine. I’m using Python 2.6.5, wxPython 2.8.11.0 and py2exe 0.6.9, and the dist was created with “setup.py py2exe” in py2exe/samples/simple. The top of the test_wx.py file shows
import wx
from wx.lib.pubsub import setupv1
from wx.lib.pubsub import Publisher
and the setup.py has the py2exe options set to
options = {
“py2exe”: {
“dll_excludes”: [“MSVCP90.dll”],
“packages”: [‘wx.lib.pubsub’],
}
I can send you the .zip of the dist that gets created. I tested that it works on a machine without Python or VC redistributable.
Oliver
···
On Thu, Jun 17, 2010 at 10:08 AM, Mike Driscoll kyosohma@gmail.com wrote:
Mike, I just noticed that the traceback you show indicates you are using the new API, not v1, so perhaps you meant you were trying setuparg1. Either way, py2exe’ing still works with my setup (replace “from wx.lib.pubsub import setupv1” with “from wx.lib.pubsub import setuparg1” and redo the py2exe).
Mike I don’t know what else to say: as mentioned, it works flawlessly on my machine. I’m using Python 2.6.5, wxPython 2.8.11.0 and py2exe 0.6.9, and the dist was created with “setup.py py2exe” in py2exe/samples/simple. The top of the test_wx.py file shows
import wx
from wx.lib.pubsub import setupv1
from wx.lib.pubsub import Publisher
and the setup.py has the py2exe options set to
options = {
“py2exe”: {
“dll_excludes”: [“MSVCP90.dll”],
“packages”: [‘wx.lib.pubsub’],
}
I can send you the .zip of the dist that gets created. I tested that it works on a machine without Python or VC redistributable.
Oliver
On Thu, Jun 17, 2010 at 10:08 AM, Mike Driscoll kyosohma@gmail.com wrote:
Ah-ha! I didn't even know I was using the new API. I'll give it
another go then and let you know. Sorry for my obvious confusion!
···
On Jun 17, 9:37 pm, oliver <oliver.schoenb...@gmail.com> wrote:
Mike, I just noticed that the traceback you show indicates you are using the
new API, not v1, so perhaps you meant you were trying setuparg1. Either way,
py2exe'ing still works with my setup (replace "from wx.lib.pubsub import
setupv1" with "from wx.lib.pubsub import setuparg1" and redo the py2exe).
Oliver