<p>我猜你用的是<a href="http://www.wxpython.org" rel="noreferrer">wxPython</a>的版本,也就是<code>>= 2.8.11.0</code>?如果是,则<code>wx.lib.pubsub</code>包已更改。<a href="http://wiki.wxpython.org/WxLibPubSub" rel="noreferrer">This page</a>描述了这些更改。在<a href="http://www.wxpython.org" rel="noreferrer">wxPython</a>邮件列表<a href="http://groups.google.com/group/wxpython-users/browse_thread/thread/d448a42abdae3e69/318cc65f2b54348f" rel="noreferrer">here</a>上也有一个线程讨论这个问题。</p>
<p>为了使这一切在我的项目中工作,我做了下面描述的<a href="http://groups.google.com/group/wxpython-users/msg/03dbfca87bee4830" rel="noreferrer">here</a>这是上面邮件列表线程的一部分。我总结如下:</p>
<blockquote>
<p>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": </p>
<pre><code># only in app's startup module
from wx.lib.pubsub import setuparg1
# in all modules that use pubsub
from wx.lib.pubsub import pub as Publisher
</code></pre>
<p>and replace any occurence of <code>"Publisher()." by "Publisher."</code></p>
</blockquote>
<p>然后在我的<code>setup.py</code>脚本中,我必须向选项添加以下内容:</p>
<pre><code>options = {
"py2exe": {"packages": ['wx.lib.pubsub']}
}
setup(data_files=data_files,
windows=[
{'script': 'btpos.py'],
options=options)
</code></pre>
<p>现在,您应该能够使用新版本的pubsub构建可执行文件,但使用的是旧的api。您可能还想查看pubsub的新v3 api。如果你的项目不是太大,你也许可以在不改变太多的情况下度过难关。</p>