YOLOv5打包成exe常见问题记录

yolov5常见问题

问题1:FileNotFoundError: [Errno 2] No such file or directory: ‘./hubconf.py’

这个包,是动态加载的一个包。在打包命令中,加上–hidden-import hubconf。(没有验证过去掉它是否可行),并且在打包好的dist\your_project_name\xxx.exe的所在目录,把hubconf.py复制到这个exe所在的目录下

问题2:模型权重文件,或者配置文件(ultralytics\cfg\default.yaml)找不到。 解决方法

1 复制权重文件到exe所在目录。
2 根据报错提示的配置文件路径,把default.yaml复制放到相应的路径下。(缺少相应父级文件夹的,手工创建)。
例子:这里提示 dist\your_project_name\ultralytics\cfg\default.yaml找不到,那么在dist\your_project_name\目录下,依次创建ultralytics目录,并在ultralytics目录下创建cfg目录,并在cfg目录下,复制default.yaml到cfg目录下。这个default.yaml即https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/default.yaml 文件。也是yolov5_p38\Lib\site-packages\ultralytics\cfg\default.yaml

一般这个文件yolov5项目目录是有的。copy放到该位置或者命令行添加上也可以

问题3:FileNotFoundError: [WinError 3] 系统找不到指定的路径 ‘D:\xxx\dist\xxxx\utils\general.pyc’

把yolov5下utils文件夹复制到你打包的文件夹里面,即dist/detect/下,然后把general.py复杂一份,改名为general.pyc就行。我也不知道这是为什么,但他就是能跑了

问题4: windows Server2012R2 Windows Server 2012 R2 DataCenter 64bitCN ImportError: DLL load failed while模块不存在问题?

解决办法也简单,在服务器管理 --> 添加角色和权限 -->桌面体验即可勾选上即可,这里会重启几分钟。需要在空闲时操作

在这里插入图片描述

问题5: default.yaml missing from from yolo/configs folder

pyinstaller --onedir --collect-all ultralytics file.py

I encountered a similar issue to what @YuccaBrev described. In my case, I faced the error while utilizing --onefile with pyinstaller.
To tackle this problem:
Use the --onedir command alongside pyinstaller.
After generating the .exe, check if it’s working properly. If the error persists, indicating the absence of ‘data.yaml’:
Verify if the ‘ultralytics’ folder is created by pyinstaller; if not, proceed to the next step.
Manually create the ‘ultralytics\cfg’ directory under the same directory as the generated .exe.
Add the ‘data.yaml’ file within the ‘ultralytics\cfg’ directory.
This adjustment enabled the .exe file to run successfully without encountering the missing ‘data.yaml’ error.

问题6: The ‘pathlib’ package is an obsolete backport of a standard library package and is incompatible with PyInstaller. Please remove this package (located in C:\Users\alpha\anaconda3\lib\site-packages) using conda remove then try again

conda uninstall pathlib

以下是我的打包命令

#注意这里我用的是anaconda 虚拟环境
#先安装 pyinstaller 模块
pip install pyinstaller

#提示缺少ultralytics / 也可以 --collect-all ultralytics 进行绑定
pip install ultralytics

pyinstaller --onedir --noconsole --add-data="data:data" --add-data="models:models" --add-data="utils:utils" --collect-all ultralytics --name "yolov5_detect" .\predict.py

到这里大功告成~

JAVA、Python、VUE可交流学习,可开发
微信号: mkingxiaohao

在这里插入图片描述
公众号不定时发布可用资源
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值