pyinstaller打包 包含torch yolov5

1 篇文章 0 订阅
1 篇文章 0 订阅

打包不成功

Windows7上安装pytorch1.11后报api-ms-win-core-path-l1-1-0.dll错误的解决方法_fengbingchun的博客-CSDN博客_api-ms-win-core-path-l1-1-0.dll

1.成功打包但闪退

可通过start ./dist/main/main.exe执行检查打包后的文件是否正常执行

cd 到dist/main,控制台执行.main.exe  会打印错误

2.缺少importlib_resource/version.txt

pip freeze >version.txt(不知道有没有用,后面再没有这个错误了)

3.ico图标

通过工具格式转化ico格式可以用

4.import cv2问题

查发现版本不对应。opencv-pythton 版本4.6.0.66,pyinstaller3.5

pyinstaller 3.5 opencv-python版本

降低到4.5.3.56

查到还有一个auto-py-to-exe也可以通过pip安装来完成打包

torch==1.8.0

torchvision==0.9.0

pyinstaller版本3.5,据说太低,改成4.9了

参考的方法:

pyinstaller 命令_使用PyInstaller轻松分发Python应用程序_weixin_39617318的博客-CSDN博客

使用PyInstaller轻松分发Python应用程序 - 腾讯云开发者社区-腾讯云

pyinstaller打包带有torch库的python文件转成exe(win10+cuda11.1+Pytorch1.7.1+python3.8)_少有人走的路_心智旅程的博客-CSDN博客_pyinstaller torch

Pyinstaller打包torch程序终极保姆级历程-预防解决若干问题以及防止打包文件过大_马布奇诺的博客-CSDN博客_pyinstaller torch

用pyinstaller将用pytorch训练好分类器打包成.exe文件_我不会coding的博客-CSDN博客_pytorch打包成exe

使用pyinstaller将训练好的目标检测算法(基于pytorch)打包成一个exe文件(完整过程)_qq_37516798的博客-CSDN博客

Pyinstaller 打包pytorch应用(Yolov5为例)_小熊果汁的博客-CSDN博客_pyinstaller打包pytorch

总结使用pyinstaller打包pyqt5以及pytorch的各种坑_Nie_Hen的博客-CSDN博客

pyinstaller导出pytorch深度学习模型_qq_38856833的博客-CSDN博客_pyinstaller pytorch

windows pyinstaller打包pytorch程序到exe文件_mikeyNa的博客-CSDN博客_pytorch打包成exe

重新打包行后验证

1.可通过start ./dist/main/main.exe执行检查打包后的文件是否正常执行

2.cd 到dist/main,控制图执行.main.exe  会打印错误

若torch版本太高

torchvision版本也要对应

【问题】torch和torchvision对应版本_Jackilina_Stone的博客-CSDN博客_torch和torchvision对应版本

找不到torch模块

python 进入测试import torch可以正常运行(不知道为什么明明有却提示找不到这个模块,再重试又没有了。。。)

重试打包:

pyinstaller -D main.py  --icon=resource/img/AppIcon.ico

修改main.spec

datas=[

('config.json', '.'),('monicamera.py', '.'),('image', 'image'),('test', 'test'),('muban', 'muban'),('resource','resource')],

hiddenimports =['torch', 'dbm','data_file', 'MYQTUI','yolov5']

修改后再执行:

pyinstaller main.spec

生成dist build 

cd dist/main

main.exe

验证打包成果

python中socket.gaierr errno1104_“socket.gaierror:[Errno 11004]getaddrinfo失败”

发现会github下载,把.pt文件加入到dist/main中

config.json配置文件将数据库的本机地址改成localhost,相机ip设置为127.0.0.1

打包成文件夹 并指定图标文件(-F是exe文件 -w不带控制台)

pyinstaller -D  main.py --icon=resource/img/ison.ico

修改main.spec内的导入文件data和hiddenimport  带控制台console=True

pyinstaller main.spec

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
为了通过pyinstaller打包yolov5,你可以按照以下步骤进行操作: 1. 首先,确保你已经安装了pyinstaller。你可以使用命令`pip install pyinstaller`来进行安装。 2. 引用提供了另一种安装pyinstaller的方法,你可以使用命令`pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip`来安装最新的开发pyinstaller。 3. 接下来,你需要下载yolov5的权重文件。引用中提供了一个百度网盘的链接,你可以下载yolov5s.pt权重文件并将其放在项目文件夹的`./yolov5/weights`目录下。 4. 然后,将一张用于测试的图片命名为`test.png`并将其放在`./yolov5`目录下。 5. 最后,执行以下命令来测试pyinstaller打包:`python detect.py --source test.png --weights weights/yolov5s.pt`。这个命令将使用yolov5s权重文件对测试图片进行目标检测。 6. 你可以使用pyinstaller打包你的代码。确保你已经进入到包含你的代码的目录,并使用以下命令:`pyinstaller your_script.py`。这个命令将生成可执行文件。 7. 打包完成后,你可以在生成的`dist`目录中找到你的可执行文件。 请注意,在引用中提到,如果你直接使用pip安装pyinstaller,然后使用pyinstaller打包时遇到找不到某些库的问题,你可以尝试使用引用中提供的方法安装最新的开发pyinstaller,这可能会减少一些包找不到的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [pyinstaller 打包yolov5和deepsort项目打包部,win10平台](https://blog.csdn.net/Yang_4881002/article/details/123889561)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [在ubuntu系统上用pyinstaller加密打包yolov5项目代码的详细步骤](https://blog.csdn.net/qq_30841655/article/details/128583336)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值