44

PyInstaller 打包调用 PaddleOCR 的程序

 2 years ago
source link: https://enoch2090-blog.vercel.app/pyinstaller-pack-paddleocr
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

PyInstaller 打包调用 PaddleOCR 的程序

2022 年 8 月 9 日
如果你去 Paddlepaddle 的 GithHub Issue 看,会发现特别多的 issue 是讨论为什么用 PyInstaller 打包不成功的。读了一些源码,我觉得导致这种情况的部分原因是 Paddlepaddle 本身的 import 做得不规范导致的;另一部分原因是它毕竟是一个深度学习库,用了不少动态链接库和其它外部文件。
这里整理一下我试下来行之有效的打包方法。
然后双击打包出来 dist/main.exe,就可以正常运行。
待我有空分析一下为什么会这样。
paddleocr打包exe,10大报错的解决。。。。成功打包运行_Joyce1001的博客-CSDN博客_paddle打包exe
打包paddleocr时,出现Error: Can not import avx core while this file exists: xxxxxx(你安装Python的径)\paddle2.0\lib\site-packages\paddle\fluid\core_avx.pyd错误: 解决方法:进入paddle安装对应的虚拟环境下,如下图所示,找到paddle/libs,如下所示: Copy所有的dll文件到dist下的: pyinstaller可执行文件报错astor: 解决方法: 注销这三行。重新打包。 或者通过降低astor的版本:目前电脑上0.8.1,降到0.7.1即可。 3.打包中出现:SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape编码问题,是路径转义问题,只需要把反斜杠'\'改为正斜杠'/'即可。 打包paddleoce为exe文件出现错误的参考内容: https://blog.csdn.net/aqqwvfbukn/article/details/120553124?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163754255816780366519388%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=163754255816780366519388&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allfirst_rank_ecpm_v1~rank_v31_ecpm-1-120553124.pc_search_result_cache&utm_term=%E6%88%90%E5%8A%9F%E8%A7%A3%E5%86%B3-PaddleOCR%E6%89%93%E5%8C%85exe-Pyinstaller&spm=1018.2226.3001.4187 4.遇到importlib.metadata not found from "prettytable"的错误:解决方法:在site-packages/Pyinstaller/hooks目录下增加一个文件:hook-ctypes.macholib.py,内容如下。可解决。 from PyInstaller.utils.hooks import copy_metadata datas = copy_metadata('prettytable') 5.在指定的环境路径下打包的方法: pyinstaller network.py -p C:\Users\flysky\PycharmProjects\JMQapp\venv\Lib\site-packages 6.framework_pb2的错误:把site_pacages下的proto移到dist\paddle_image\paddle\fluid 7.注意: Python的那个坑爹设定,不会把项目入口的当前目录当做package,所以包与python文件不要放一起。 8.错误:File "ppocr\utils\e2e_utils\pgnet_pp_utils.py", line 25, in ModuleNotFoundError: No module named 'extract_textpoint_slow'的解决方法:把ppocr文件包移到dist目录下面。 9.错误:File "skimage\feature\orb_cy.pyx", line 13, in init skimage.feature.orb_cy ModuleNotFoundError: No module named 'skimage.feature._orb_descriptor_positions' 增加spec文件中的hiddenimports=['framework_pb2','scipy.special.cython_special','skimage','skimage.feature._orb_descriptor_positions'], 10.最后把配置文件转到dist文件夹下面。 总结:dll文件、ppocr、配置文件、hidden-import解决,完美!
paddleocr打包exe,10大报错的解决。。。。成功打包运行_Joyce1001的博客-CSDN博客_paddle打包exe
https://blog.csdn.net/Joyce1001/article/details/121509765

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK