更新pyinstaller以后,再也没有如丝般顺滑的一键打包体验,各种报错。网上搜了解决方案,成功debug。汇总如下。
1、ImportError: No module named ‘xxx’
打开.spec文件
添加hiddenimports=['xxx'],
然后打开命令窗口:pyinstaller C:\***.spec
总之报什么错就把啥加进去,简单粗暴。
2、添加路径
还是打开.spec文件,把该加路径的都加进去
pathex=['D:\\ProgramData\\anaconda\\Lib\\site-packages', 'C:\\Users\\cgz','D:\\ProgramData\\anaconda\\pkgs','D:\ProgramData\anaconda\DLLs'],
3、it could not find or load the Qt platform plugin "windows"
Qt目录里找到platforms,全部复制到打包程序的根目录(dist目录),再运行程序就不会报错了。
4、Cannot find existing PyQt5 plugin directories这个没试过,大家试下行不行
5、Unable to find Qt5 translations C:/qt5b/qt_1524647842210/_h_env/Library/translations\qtbase_*.qm.
找到...Lib\site-packages\PyInstaller\utils\hooks\qt.py文件。
6、unable to find Qt5Core.dll on PATH
并在导入PyQt5之前导入上述脚本
pyinstaller --path C:\Python36\Lib\site-packages\PyQt5\Qt\bin name.py