python2.7-wxpython4.0.1-pyinstaller打包的正确用法

简介: hi 各位看官,本文是截止2018年7月4日,基于python2.7开发wxpython时的打包正确用法。(2018年11月16日,发现pyinstall 3.4版本解决了这个问题了)

hi 各位看官,本文是截止2018年7月4日,基于python2.7开发wxpython时的打包正确用法。(2018年11月16日,发现pyinstall 3.4版本解决了这个问题了)

坑1:

wxpython的最新版本为4.0.3 但是因为4.0.3引入了新的pubsub 4.0 不兼容python2.7。所以如果用python2.7的同学必须降级到wxpython 4.0.1版本

坑2:

打包方面,我们可以用pyinstaller打包。但是pip上,pyinstaller最新的版本是3.3.1 版本,此版本上有bug https://github.com/pyinstaller/pyinstaller/issues/2215

但是后期,pyinstall的作者修复了此bug在dev版本上,所以我们只有去github上 安装最新的dev版本才能打包成功

踩坑表现:

Traceback (most recent call last):
  File "<string>", line 41, in <module>
  File "<string>", line 36, in walk_packages
  File "<string>", line 20, in walk_packages
  File "d:\program files\python\python27\lib\site-packages\wx-3.0-msw\wx\lib\pubsub\core\arg1\__init__.py", line 16, in <module>
    raise RuntimeError(msg)
RuntimeError: Should not import this directly, used by pubsub.core if applicable

出现pubsub报错,因为wxpython 2.8.0之前的版本用的是\core\arg1\ 所以为了能顺利打包,我们要进行如下操作:

填坑方法:

1.pip装wxpython 4.0.1版本

pip install wxpython==4.0.1

2.pip装dev版本pyinstaller

pip install git+https://github.com/pyinstaller/pyinstaller

3.重新打包主入口main.py

pyinstaller -D main.py
目录
相关文章
|
1月前
|
测试技术 Python
Python中的装饰器:概念、用法和应用
【4月更文挑战第6天】 装饰器是Python中的一个重要概念,它允许我们在不修改原始函数代码的情况下,增加或修改函数的行为。本文将深入探讨装饰器的概念、用法和应用,帮助读者更好地理解和使用这一强大的工具。
|
1天前
|
Python
【Python操作基础】——while语句用法和pass语句
【Python操作基础】——while语句用法和pass语句
|
1天前
|
Python
【Python操作基础】——for语句用法
【Python操作基础】——for语句用法
|
1天前
|
Python
【Python操作基础】——if语句用法
【Python操作基础】——if语句用法
|
4天前
|
数据采集 NoSQL 中间件
python-scrapy框架(四)settings.py文件的用法详解实例
python-scrapy框架(四)settings.py文件的用法详解实例
9 0
|
4天前
|
存储 数据采集 数据库
python-scrapy框架(三)Pipeline文件的用法讲解
python-scrapy框架(三)Pipeline文件的用法讲解
7 0
|
4天前
|
存储 数据采集 JSON
python-scrapy框架(二)items文件夹的用法讲解
python-scrapy框架(二)items文件夹的用法讲解
11 0
|
4天前
|
数据采集 前端开发 中间件
python-scrapy框架(一)Spider文件夹的用法讲解
python-scrapy框架(一)Spider文件夹的用法讲解
10 0
|
13天前
|
Python 容器
Python中的for循环用法详解,一文搞定它
Python中的for循环用法详解,一文搞定它
|
13天前
|
Linux iOS开发 MacOS
pyinstaller---Python代码的打包神器,一键将python代码打包成exe可执行文件
pyinstaller---Python代码的打包神器,一键将python代码打包成exe可执行文件