windows pydt5 打包总结

windows系统+python3+pyqt5+pyinstaller打包,经常会出现各种打包异常情况。
如果代码没有特别异常,那么综合原因,大抵都是这四个元素之间的匹配问题,引起的。

1.windows系统的版本和位数 (mac系统和linux 没有进行测试过)
2.python3的版本和位数
3.pyqt5的版本和位数 (如果pip安装,则位数同python3)
4.pyinstaller的版本和位数(一般pip安装,无需考虑位数)

坑1.pyinstaller打成的包,可以在64位操作系统使用,无法在32位操作系统使用

坑的成因:
1.python存在64位版本和32位版本。
2.64位版本打成的包,只能在64位操作系统使用。
3.32位版本打成的包,即可以在64位操作系统使用,也可以在32位操作系统使用。

解决方案:
1.重新安装32位版本的python,进行开发。

坑2.pyinstaller打成的包,可以在win7以上操作系统使用,无法在xp操作系统使用

坑的成因:
1.python3 从3.5版本开始,就已经不支持xp操作系统了。

解决方案:
2.重新安装3.4版本的python,进行开发。

坑3.pyqt5应用,开发运行时是正常,但pyinstaller打成的包,界面失真变丑。

坑的成因:
1.pyinstaller 不支持最新版本的pyqt5。

解决方案:
2.重新安装低版本的pyqt5,进行开发。(当前推荐:5.8.2版本)
命令

pip uninstall pyqt5
pip install pyqt5==5.8.2

坑4.pyqt5应用,开发运行时是正常,但pyinstaller打成的包,无法运行,提示failed to execute script xxx。

坑的成因:(同坑3)
1.pyinstaller 不支持最新版本的pyqt5。

解决方案:(同坑3)
2.重新安装低版本的pyqt5,进行开发。(当前推荐:5.8.2版本)
命令

pip uninstall pyqt5
pip install pyqt5==5.8.2

坑5.pyqt5应用,开发运行时是正常,但pyinstaller无法打包成功。

坑的成因:(同坑3)
1.pyinstaller 不支持最新版本的pyqt5。

解决方案:(同坑3)
2.重新安装低版本的pyqt5,进行开发。(当前推荐:5.8.2版本)
命令

pip uninstall pyqt5
pip install pyqt5==5.8.2

坑6.pip install pyqt5,安装不了pyqt5,提示找不到资源。

坑的成因:
1.你的python3可能是最新版本,pyqt5-tools还不支持最新版本的python3

解决方案:
2.重新安装低版本的python3,进行开发。(当前推荐:3.6.6版本)

坑7.pip install pyqt5-tools,安装不了pyqt5-tools,提示找不到资源。

坑的成因:
1.你的python3可能是最新版本,pyqt5-tools还不支持最新版本的python3

解决方案:
2.重新安装低版本的python3,进行开发。(当前推荐:3.6.6版本)

坑8.pip install pyqtchart,但是安装不了pyqtchart。

坑的成因:
1.pyqtchart对pyqt5的版本有依赖需求。

解决方案:
2.针对pyqt5的版本进行安装。
命令如: pip install pyqtchart==5.8

坑9.pip install pyqtdatavisualization,但是安装不了pyqtdatavisualization。

坑的成因: (同坑8)
1.pyqtdatavisualization对pyqt5的版本有依赖需求。

解决方案:(同坑8)
针对pyqt5的版本进行安装。
2.命令如: pip install pyqtdatavisualization==5.8

坑10.python3的orm技术,使用sqlalchemy模块,开发运行时都是正常的,但pyinstaller打成的包,数据库执行异常。

坑的成因:
1.pyinstaller打成的包,在执行连表后的对象属性读取时,失败。

解决方案:
2.找不到好的解决方法,只能换回sql语言来完成。(如有好的解决方法,敬请留言告知)

坑11.windows10 下安装pyinstaller pywin32

坑的成因:
1.无法通过win32接口访问windows系统
解决办法
检查是否正确安装win32
经检查可以使用pypiwin32 替代PyWin32

ImportError: DLL load failed

用 PyInstaller 给程序打包的时候遇到了pyi_rth_qt5plugins returned -1 的 Fatal Error 提醒。这个错误信息几乎是毫无用处的,修改 .spec 文件,打开 debug 模式以及显示 console 后,在 running pyi_rth_qt5plugins.py的时候发生了 ImportError: DLL load failed 找不到指定的模块 错误。
回头想起了在编译的时候看到了很多WARNNING消息,回过头查看,发现了很多 lib not found 的问题。但是仔细检查了 Python 库之后,这些 DLL 明明在 C:\Python35-32\Lib\site-packages\PyQt5\Qt\bin 目录下,最后的搜索得到的解决办法是把这个目录添加到环境变量里。
问题得到了解决,猜测原因是因为之前使用 pip 安装 PyQt 的时候, pypi.python.org 总是连接不顺畅,最后去下了个 .whl 文件直接安装,导致没有对应环境变量打包的时候找不到 DLL。

环境: Python == 3.5.2 ,PyInstaller == 3.1.1
10951 WARNING: lib not found: Qt5Svg.dll dependency of C:\python35-32\lib\site-packages\PyQt5\Qt\plugins\imageformats\qsvg.dll
11206 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35-32\lib\site-packages\PyQt5\Qt\plugins\imageformats\qsvg.dll
11437 WARNING: lib not found: Qt5Core.dll dependency of C:\python35-32\lib\site-packages\PyQt5\Qt\plugins\imageformats\qsvg.dll
11763 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35-32\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtga.dll
12017 WARNING: lib not found: Qt5Core.dll dependency of C:\python35-32\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtga.dll
12224 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35-32\lib\site-packages\PyQt5\Qt\plugins\platforms\qminimal.dll
12418 WARNING: lib not found: Qt5Core.dll dependency of C:\python35-32\lib\site-packages\PyQt5\Qt\plugins\platforms\qminimal.dll
12625 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35-32\lib\site-packages\PyQt5\Qt\plugins\platforms\qwindows.dll
12833 WARNING: lib not found: Qt5Core.dll dependency of C:\python35-32\lib\site-packages\PyQt5\Qt\plugins\platforms\qwindows.dll
api-ms-win-crt-runtime 错误

PyInstaller 打包之后的程序运行的时候发生 api-ms-win-crt-runtime动态库之类的错误,似乎只有在 Python 3.5 下打包才会遇到。因为 Universal CRT (KB2999226)缺失,可以通过安装此更新来解决问题。或者直接下载 Visual C++ Redistributable (x86 ,x64 )。
参考链接:api-ms-win-crt-runtime-l1-1-0.dll is missing when open office file

希望能帮到大家,欢迎继续补充!!

你可能感兴趣的:(windows pydt5 打包总结)