pyinstaller系列之七:打包各种问题汇总
在使用pyinstaller打包的整个过程中,遇到不少问题,在此总结一下。后面遇到会继续更新!
1. 在64下可运行,不能在32位下运行
解决:在32位系统下打包,可以参考 https://blog.csdn.net/u012219045/article/details/1153206192. RecursionError:maximum recursion depth
解决:在xxx.spec文件开始增加两行:import syssys.setrecursionlimit(5000)
再执行打包:pyinstaller xxx.spec
3. UnicodeDecodeError:'utf-8' codec can't decode byte 0xce in position 122:invalid continuation byte
解决:在你打包的命令行中先输入chcp 65001 然后再输入打包命令。4. 使用了多进程 multiprocessing 模块
解决:必须调用 multiprocessing.freeze_support(),直接在“if __name__ == '__main__'”之后调用5. 打包PyQt5闪退
原因:可能未找到某个文件
解决办法:
1. 把需要读取的文件及其其他资源 都放到dist中。
2. 打包成exe的话,需使用 --add-data 附加。可参考:https://blog.csdn.net/u012219045/article/details/1148412876. WARNING:file already exists but should not:_C.cp37-win_amd64
解决:报错内容可能不同,但都是xxx已存在,问题的原因是pyinstaller打包时多打了一次,所以会报已经存在了。
这个解决方案就是把多余的去掉。在自动生成的xxx.spec中,在 a 和 PYZ 中间添加如下代码,去掉多余依赖项for d in a.datas:if '_C.cp37-win_amd64' in d[0]:a.datas.remove(d)break
7. Hidden import "xxx" not found!
Hidden import "pkg_resources.markers" not found!
Hidden import "pkg_resources.py2_warn" not found!
Hidden import "MySQLdb" not found!
Hidden import "sqlalchemy.sql.functions.func" not found!
Hidden import "mx.DateTime" not found!
解决: hiddenimports=['pkg_resources.markers', 'pkg_resources.py2_warn', '...']8. 打包的时候出现了很多warning:lib not found...dll, 原因是pyinstaller 没有办法识别到这些dll
解决办法:copy warning中一些dll文件的名字,再电脑中搜索到他们的路径!添加到环境变量里面
WARNING:lib not found:msmpi.dll dependency of d:\programdata\anaconda3\Library\bin\mkl_blacs_msmpi_ilp64.dll
WARNING:lib not found:impi.dll dependency of d:\programdata\anaconda3\Library\bin\mkl_blacs_intelmpi_lp64.dll
WARNING:lib not found:msmpi.dll dependency of d:\programdata\anaconda3\Library\bin\mkl_blacs_msmpi_lp64.dll
WARNING:lib not found:impi.dll dependency of d:\programdata\anaconda3\Library\bin\mkl_blacs_intelmpi_ilp64.dll
WARNING:lib not found:mpich2mpi.dll dependency of d:\programdata\anaconda3\Library\bin\mkl_blacs_mpich2_lp64.dll
WARNING:lib not found:mpich2mpi.dll dependency of d:\programdata\anaconda3\Library\bin\mkl_blacs_mpich2_ilp64.dll
WARNING:lib not found:pgf90.dll dependency of d:\programdata\anaconda3\Library\bin\mkl_pgi_thread.dll
WARNING:lib not found:pgf90rtl.dll dependency of d:\programdata\anaconda3\Library\bin\mkl_pgi_thread.dll
WARNING:lib not found:pgc14.dll dependency of d:\programdata\anaconda3\Library\bin\mkl_pgi_thread.dll
WARNING:lib not found:torch_python.dll dependency of d:\programdata\anaconda3\lib\site-packages\torch\_C.cp37-win_amd64.pyd9. 切换了虚拟环境打包,报DLL无法导入,实际是打包时还在使用旧的虚拟环境
解决: 打包时指定虚拟环境:-p。可参考: https://blog.csdn.net/u012219045/article/details/11361247510. DecodeEncodeError
解决: 检查执行路径中是否有中文,非Acsii码,换成英文路径。Python文件开头加 #-*-coding:utf-8-*-11. Pyqt5 打包后会出现错误:"QThread:Destroyed while thread is still running"
解决办法1:启动QThread使用了start(), 改为run() 可解决,但这样会卡主UI线程
解决办法2:依然使用start(),再追加一句 exec()。推荐这样!12. No module named 'sklearn.xx'
43852 WARNING: Hidden import "sklearn.utils.sparsetools._graph_validation" not found!
43854 WARNING: Hidden import "sklearn.utils.sparsetools._graph_tools" not found!
43866 WARNING: Hidden import "sklearn.utils.lgamma" not found!
No module named 'sklearn.utils._cython_blas'
No module named 'sklearn.neighbors._typedefs'
No module named 'sklearn.neighbors._quad_tree'
No module named 'sklearn.tree'
No module named 'sklearn.tree._utils'
解决:hiddenimports=['sklearn', 'sklearn.tree', 'sklearn.tree._utils', 'sklearn.neighbors._quad_tree',
'sklearn.neighbors._typedefs', 'sklearn.utils._cython_blas',
'sklearn.utils.sparsetools._graph_validation',
'sklearn.utils.sparsetools._graph_tools', 'sklearn.utils.lgamma']
13. No module named 'scipy.special.cython_special'
解决: 使用scipy==1.4.1 或者 --hidden-import scipy.special.cython_special14. No such file or directory: 'xxx\\librosa\\util\\example_data\\registry.txt'
解决: 使用--add-data或者直接拷贝librosa下的对应文件到dist。
15. fatal error:zmq.h:No such file or directory
解决: sudo apt install libzmq3-dev16. Error loading "xxx\torch\lib\caffe2_detectron_ops_gpu.dll" or one of its dependencies
开始使用pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1,后来更换高版本torch1.7.0解决!
# pip install torch===1.7.0+cu110 torchvision===0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html17. pkg_resources.DistributionNotFound: The 'cryptography' distribution was not found and is required by the application
解决:类似这种的是缺少库,直接安装 pip install cryptography。
18. No such file or directory: '..\\xpinyin\\Mandarin.dat'
解决: 进入对应环境里的xpinyin库里,把 xpinyin\Mandarin.dat 拷贝到dist,或者.spec文件里添加: --add-data="xxx\xpinyin\*.*;.\xpinyin"
19. PyQt5.12.1 QtWebEngineWidgets must be imported before a QCoreApplication instance is created
解决:from PyQt5.QtWebEngineWidgets import * 写在运行主脚本的导入qt库的最前面!,以下是启动主脚本 client.py:
pyinstaller系列之一:简介,安装及简单使用
pyinstaller系列之二:去掉命令行,指定密码来增加反编译难度,指定可执行文件名,设置图标,清空上一次编译生成的各种文件
pyinstaller系列之三:有多个虚拟环境时如何指定python导入模块的路径
pyinstaller系列之四:如何设置打包出来的文件的版本信息。
pyinstaller系列之五:使用 --add-data 打包额外资源。
pyinstaller系列之六:适配32位系统。
pyinstaller系列之七:打包各种问题汇总。
pyinstaller系列之八:以安装包交付(windows)。
pyinstaller系列之九:构建GUI的docker镜像,docker运行GUI程序。
pyinstaller系列之十:pip安装GUI程序。
pyinstaller系列之十一:exe 反编译到 源码 尝试
pyinstaller系列之七:打包各种问题汇总相关推荐
- .NET 并行(多核)编程系列之七 共享数据问题和解决概述
.NET 并行(多核)编程系列之七 共享数据问题和解决概述 原文:.NET 并行(多核)编程系列之七 共享数据问题和解决概述 .NET 并行(多核)编程系列之七 共享数据问题和解决概述 前言:之前的文 ...
- 线程的调度、优先级和亲缘性——Windows核心编程学习手札系列之七
线程的调度.优先级和亲缘性 --Windows核心编程学习手札系列之七 每个线程都拥有一个上下文结构,在线程的内核对象中,记录线程上次运行时该线程的CPU寄存器状态.Windows会每隔20ms左右查 ...
- nginx高性能WEB服务器系列之七--nginx反向代理
nginx系列友情链接: nginx高性能WEB服务器系列之一简介及安装 https://www.cnblogs.com/maxtgood/p/9597596.html nginx高性能WEB服务器系 ...
- nginx系列之七:限流配置
** 前言 ** nginx系列之一:nginx入门 nginx系列之二:配置文件解读 nginx系列之三:日志配置 nginx系列之四:web服务器 nginx系列之五: 负载均衡 nginx系列之 ...
- 《视频直播技术详解》系列之七:现代播放器原理
七牛云于 6 月底发布了一个针对视频直播的实时流网络 LiveNet 和完整的直播云解决方案,很多开发者对这个网络和解决方案的细节和使用场景非常感兴趣. 结合七牛实时流网络 LiveNet 和直播云解 ...
- ASP.NET企业开发框架IsLine FrameWork系列之七--AppLogProvider日志框架(上)
ASP.NET企业开发框架IsLine FrameWork系列之七--AppLogProvider日志框架(上) 日志与异常 部署系统以后,管理员需要有一套强大的日志系统来诊断和修复配置上的问题,这就 ...
- PowerBI最全可视化视图打包和DEMO汇总
PowerBI最全可视化视图打包和DEMO汇总 PowerBI最强大的可视化对象,可以帮助你实现丰富炫酷的报表,但是由于可视化对象很多,一一下载研究较为麻烦,于是本人帮你完成了这个工作. 本人通过下载 ...
- IT职场人生系列之七:学外语
本文是IT职场人生系列的第七篇. 这是一篇旧文,因为很符合系列思想,所以重新粘贴一下保持系列完整性. 本人是非常相信<功夫熊猫1>中的思想的:只要有勇气并掌握了学习方法,什么困难都能解决, ...
- perp系列之七:perp手册
perp系列之七:perp手册 版本说明 版本 作者 日期 备注 0.1 ZY 2019.5.29 初稿 目录 文章目录 perp系列之七:perp手册 版本说明 目录 1.该发行版包括以下手册页 p ...
最新文章
- IntelliJ IDEA 自动编译功能无法使用,On 'update' action:选项里面没有update classes and resources这项...
- nodejs之async异步编程
- Silverlight 多窗口的实现.
- [react] 自定义组件时render是可选的吗?为什么?
- mysql outfile csv_sql-MySQL导出到outfile:CSV转义字符
- 【视频特辑】数据分析师必备,快速制作一张强大好用的大宽表
- 【渝粤教育】国家开放大学2018年秋季 1018t国际公法 参考试题
- PHP报错 Fatal error: Cannot use object of type stdClass as array
- HANA学习笔记1-搭建HANA学习环境
- ArcGIS软件应用(一)——专题图制作
- dimm和udimm_服务器内存UDIMM与RDIMM有什么区别
- 瀚高DB兼容MySQL if函数
- 容斥原理和概率与数学期望
- agx 安装ros opencv_ROS基础
- JavaScript中字符串连接/拼接的四种方式
- python画空心圆图_OpenCV-Python系列之绘图功能
- 地图如何适应 COVID-19 危机——利用 GIS 绘制飞钓地图
- 【Jailhouse 文章】Certify the Uncertified Towards Assessment of Virtualization for Mixed-criticality...
- Windows Server2016 WSUS服务部署
- eclipse maven插件问题:error occurred while automatically activating bundle org.eclipse.m2e.core.ui (525)
热门文章
- 实例分享!告诉你西门子PLC如何通过MODBUS控制变频器
- 计算机仿真的原理是相似性原理,计算机仿真中相似性原理的应用.doc
- 墨尔本大学计算机专业的课程,墨尔本大学计算机课程怎么样
- 网络工程师日常工作总结
- ACDSee Pro v5.2 英文破解版
- 报错:ch.qos.logback.core.joran.spi.JoranException
- 贝尔商道赚钱思维36道第17道:二十英里法则
- ehcache(1)---简介
- 三菱PLC各型号之间的区别
- 双轴倾角传感器的优势解答