wxpython打包报错_pyinstaller+wxpython+selinum

打包了一个桌面应用

打包命令

gui.py是你桌面应用的入口文件

pyinstaller --onefile -F gui.py

会生成dist目录,该目录下有exe

为了简单,我将程序中的用到的文件目录都改为当前目录,如

yamlPath = "./conf.yml"

这个当前目录会是你执行命令的目录,你的文件(比如上面的conf.yml)要在该目录下

建议将用到的文件都拷贝到dist目录中,并在dist目录中打开cmd运行程序

selinum我用的火狐浏览器,把驱动拷贝到dist目录

驱动路径当时写的:

self.driver = Firefox(executable_path=‘./geckodriver.exe‘, firefox_options=self.options) # 配了环境变量第一个参数就可以省了,不然传绝对路径

wxpython报了一个错误

ModuleNotFoundError: No module named ‘wx.lib.pubsub.core.publisher‘

你打开路径在core中确实找不到publisher

20200625122251037996.png

打开arg1和kwargs这里面则有publisher,咋回事

你打开__init__.py,发现注释

Core package of pubsub, holding the publisher, listener, and topicobjectmodules. Functions defined here are used internally by

pubsub so that the right modules can be found later, based on the

selected messaging protocol.

Indeed some of the API depends on the messaging

protocol used. For instance sendMessage(), definedinpublisher.py,

has a different signature (and hence implementation)forthe kwargs

protocol thanforthe arg1 protocol.

The most convenient way to

support this is to put the parts of the package that differ based

on protocolinseparate folder, and add one of those folders to

the package‘s __path__ variable (defined automatically by the Python

interpreter when __init__.py is executed). For instance, code

specific to the kwargs protocol goesinthe kwargs folder, and code

specific to the arg1 protocolinthe arg1 folder. Then when doing"from pubsub.core import listener", the correct listener.py will be

foundforthe specified protocol. The default protocol is kwargs.

Only one protocol can be usedinan application. The default protocol,ifnone is chosen by user, is kwargs, as selected by the call to

_prependModulePath() at end of thisfile.

wxpython自己会选择用哪个文件夹下的publisher

但是pyinstaller不知道,所以打包起来就报错了

我发现程序使用的是kwargs中的文件,我把kwargs中的文件拷贝到core目录下了

并在gui.py中导入

from wx.lib.pubsub.core import publisher

from wx.lib.pubsub.core import listenerimpl

这样打包后就可以运行了

写个一行命令的脚本,在exe的目录中打开cmd并运行gui.exe

cmd /k "cd /d %~dp0&&gui.exe"

出现了

20200625122251269427.png

原文地址:https://www.cnblogs.com/aidata/p/13191273.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值