rv1126 Debain rknnlite pyinstaller打包教程

参考

安装问题:
python打包exe报错:Fatal error: PyInstaller does not include a pre-compiled bootloader for your platform.

PyInstaller does not include a pre-compiled bootloader…,Checking for ‘msvc‘ C compiler

pyinstaller:AttributeError: ‘NoneType’ object has no attribute ‘find_module’

使用问题:
使用pyinstaller打包exe文件遇到的问题总结

linux环境打包python工程为可执行程序

解决pyinstaller 打包后运行exe程序出现的"ModuleNotFindError"

pyinstaller系列之五:使用 --add-data 打包额外资源

Pyinstaller打包完整python项目 使用虚拟环境的python项目的打包

pyinstaller深入使用,打包指定模块,打包静态文件

安装

建议不要直接pip install pyinstaller,这样后面打包的时候会报错

PyInstaller does not include a pre-compiled bootloader...
  • 在官方网站上下载源码包:
    https://github.com/pyinstaller/pyinstaller/releases

  • 源码包解压

  • 执行

// 进入目录并执行语句
cd bootloader
python ./waf all
 
// 安装
cd ..
python setup.py install

注意:建议下载pyinstaller4.0版本,我是python3.7环境,下载了4.5和4.4版本打包时出现错误:

pyinstaller:AttributeError: 'NoneType' object has no attribute 'find_module'

打包并测试

pyinstaller的参数可以参考:
使用pyinstaller打包exe文件遇到的问题总结

打包:

pyinstaller main.py -D -p /usr/local/lib/python3.7/dist-packages  

测试:

cd dist/main/
./main

报错:有一些第三方库没有成功打包(主要是rknn相关的)

ModuleNotFindError 

重新打包:

  • 打开main.py同级目录下生成的main.spec文件,修改hiddenimports:
hiddenimports=['psutil', 'rknnlite''ruamel.yaml'],
  • 终端输入:
pyinstaller main.spec

测试:

cd dist/main/
./main

报错:ModuleNotFind :rknnlite.api.xxx(rknn仍然没有完全打包)

打开dist/main/rknnlite文件夹以及/usr/local/lib/python3.7/dist-packages/rknnlite,对比可以发现打包仍然缺失了一些文件

解决:
直接将本地rknnlite库复制到dist/main/里

cp -r /usr/local/lib/python3.7/dist-packages/rknnlite/ /home/xxx/xxx/dist/main/

测试again:

./main

报错:(其实是打包时只打包了py文件,项目中的其他文件以及文件夹没有被一起打包)
解决:
打开main.spec文件,修改datas:

datas=[('./inference_dataset','inference_dataset'), ('./rknnmodel','rknnmodel'), ('info.cfg', '.')],

重新打包并且加上rknn库

pyinstaller main.spec
cp -r /usr/local/lib/python3.7/dist-packages/rknnlite/ /home/xxx/xxx/dist/main/

最后测试:

cd dist/main/
./main

成功运行!!!

把dist文件夹进行压缩,里面已经包括整个项目的文件以及环境配置

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值