paddleocr,windows pip 安装巨坑 lanms 库

news/2025/2/19 8:50:17/

安装 lanms 最佳参考: paddleocr,windows pip 安装巨坑 lanms 库

防丢失,直接抄录的一份


paddleocr最后几个库一个比一个难装,特别是 lanms 库,巨难装,拒绝任何花里胡哨,十分钟,三步内解决问题。

pip 下载报错

Keyring is skipped due to an exception: 'keyring.backends'
Collecting lanmsUsing cached lanms-1.0.2.tar.gz (973 kB)ERROR: Command errored out with exit status 1:command: 'C:\Users\TensorFlow\anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\TENSOR~1\\AppData\\Local\\Temp\\pip-install-46p1kew5\\lanms\\setup.py'"'"'; __file__='"'"'C:\\Users\\TENSOR~1\\AppData\\Local\\Temp\\pip-install-46p1kew5\\lanms\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\TENSOR~1\AppData\Local\Temp\pip-install-46p1kew5\lanms\pip-egg-info'cwd: C:\Users\TENSOR~1\AppData\Local\Temp\pip-install-46p1kew5\lanms\Complete output (11 lines):Traceback (most recent call last):File "<string>", line 1, in <module>File "C:\Users\TENSOR~1\AppData\Local\Temp\pip-install-46p1kew5\lanms\setup.py", line 27, in <module>if subprocess.call(['make', '--always-make','-C', BASE_DIR]) != 0:File "C:\Users\TensorFlow\anaconda3\lib\subprocess.py", line 339, in callwith Popen(*popenargs, **kwargs) as p:File "C:\Users\TensorFlow\anaconda3\lib\subprocess.py", line 800, in __init__restore_signals, start_new_session)File "C:\Users\TensorFlow\anaconda3\lib\subprocess.py", line 1207, in _execute_childstartupinfo)FileNotFoundError: [WinError 2] 系统找不到指定的文件。----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

是以上这样或者是,下载好了一部分后面直接报错(无法复原了)。

第一步 上 github 下载 C 语言版本自行编译

https://github.com/SakuraRiven/LANMS

上面是网址。

 内容是这个样子,下载后安装他说的使用 python setup.py bdist_wheel 进行编译。

注意:报错

(venv3) D:\study\配料表分析\lanms-master>python setup.py bdist_wheel
Traceback (most recent call last):File "setup.py", line 27, in <module>if subprocess.call(['make', '--always-make','-C', BASE_DIR]) != 0:File "C:\Users\TensorFlow\anaconda3\lib\subprocess.py", line 339, in callwith Popen(*popenargs, **kwargs) as p:File "C:\Users\TensorFlow\anaconda3\lib\subprocess.py", line 800, in __init__restore_signals, start_new_session)File "C:\Users\TensorFlow\anaconda3\lib\subprocess.py", line 1207, in _execute_childstartupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
if subprocess.call(['make', '--always-make','-C', BASE_DIR]) != 0:raise RuntimeError('Cannot compile lanms in the directory: {}'.format(BASE_DIR))

我也不晓得这是缺了个什么文件,只是个判断而已注释这两行代码就好了。

第二步 pip 安装 whl 文件

运行完毕后,在dist文件夹下就能找到 whl 格式的库文件,放到环境下安装即可。

pip install lanms-1.0.2-cp37-cp37m-win_amd64.whl

到这里就算是安装完毕了,如果报错看看是不是第三步的样子。

第三步 修改库源代码

安装后运行可能还会报错,但是已经和之前不一样了,报错:

Traceback (most recent call last):File "D:/study/配料表分析/PaddleOCR-release-2.6/test.py", line 1, in <module>from paddleocr import PaddleOCRFile "D:\study\配料表分析\PaddleOCR-release-2.6\paddleocr.py", line 34, in <module>from tools.infer import predict_systemFile "D:\study\配料表分析\PaddleOCR-release-2.6\tools\infer\predict_system.py", line 33, in <module>import tools.infer.predict_det as predict_detFile "D:\study\配料表分析\PaddleOCR-release-2.6\tools\infer\predict_det.py", line 31, in <module>from ppocr.data import create_operators, transformFile "D:\study\配料表分析\PaddleOCR-release-2.6\ppocr\data\__init__.py", line 35, in <module>from ppocr.data.imaug import transform, create_operatorsFile "D:\study\配料表分析\PaddleOCR-release-2.6\ppocr\data\imaug\__init__.py", line 48, in <module>from .drrg_targets import DRRGTargetsFile "D:\study\配料表分析\PaddleOCR-release-2.6\ppocr\data\imaug\drrg_targets.py", line 21, in <module>from lanms import merge_quadrangle_n9 as la_nmsFile "C:\Users\TensorFlow\anaconda3\envs\AI\lib\site-packages\lanms\__init__.py", line 2, in <module>from .adaptor import merge_quadrangle_n9 as nms_impl
ModuleNotFoundError: No module named 'lanms.adaptor'

定位到报错的源码,读源码可以看到其实这里是个递归,不知道什么原因函数的调用出了些问题。
此处改动源码请保存好原来的源码
直接替换掉 __init __.py 文件下的代码。

import numpy as npdef merge_quadrangle_n9(polys, thres=0.3, precision=10000):if len(polys) == 0:return np.array([], dtype='float32')p = polys.copy()p[:, :8] *= precisionret = np.array(merge_quadrangle_n9(p, thres), dtype='float32')ret[:, :8] /= precisionreturn ret

后面两项直接安装: 

# 安装时注意关闭魔法
pip install lmdb
pip install tqdm

http://www.ppmy.cn/news/522173.html

相关文章

计算路由器更新之后的路由表

书P160页距离向量算法 《计算机网络第八章》4-37 假定网络中的路由器B的路由表如下所示(三项分别为“目标网络”&#xff0c;“距离”,“下一跳路由器”) N1 7 A N2 2 C N6 8 F N8 4 E N9 4 F 现在B收到来…

5G网络学习(二)——UPF用户平面功能(未完待续)

上节介绍了5G网络部署及架构&#xff0c;感兴趣的同学可以看下 5G网络部署及架构 接下来我们介绍一下5G网络架构中一个重要的部分————UPF&#xff08;用户平面功能&#xff09; UPF是3GPP核心网系统架构的重要组成部分&#xff0c;主要负责5G核心网用户面数据包的路由和转…

5G 核心网 Inter NG-RAN node N2 based handover 信令流程

文章目录 Why we talk N2 based handoverSome basic background knowledgeN2 based handover Preparation phaseN2 based handover Execution phaseIndirect tunnel summary Why we talk N2 based handover 相信大家都能轻易地读懂TS 23502的XN 切换信令流程&#xff0c;因为这…

PaddleOCR #使用PaddleOCR进行光学字符识别(PP-OCR文本检测识别)

引言&#xff1a; PaddleOCR 是一个 OCR 框架或工具包&#xff0c;它提供多语言实用的 OCR 工具&#xff0c;帮助用户在几行代码中应用和训练不同的模型。PaddleOCR 提供了一系列高质量的预训练模型。这包含三种类型的模型&#xff0c;使 OCR 高度准确并接近商业产品。它提供文…

MyBatis第三讲:MyBatis实现CRUD

五、数据层实现MyBatis基本操作 5、1实体层 创建实体类&#xff0c;用于装载数据库数据到程序中 Data NoArgsConstructor AllArgsConstructor public class Book {private Integer id;private String name;private double price; } //使用lombok实现代码简化5、2数据层 创建…

计算机考试字处理怎样加水印,一学即会!图片上如何添加文字水印

原标题&#xff1a;一学即会&#xff01;图片上如何添加文字水印 平时工作中&#xff0c;有的小伙伴经常需要处理一大堆的图片&#xff0c;比如说在网上发表自己的文章&#xff0c;在购物网站上晒单&#xff0c;还是自己亲手拍的照片&#xff0c;自己制作的图片&#xff0c;或者…

用pm2在本地部署服务器node项目,利用pm2部署多个node.js项目的配置教程

前言 相信大家应该都知道&#xff0c;一般在实际项目部署中&#xff0c;我们服务器在启动的时候需要自动启动node服务。以前是通过liunx自带的命令启动。但是随着后台微服务越来越多。每次发布新程序。修改脚本太麻烦了。于是换成PM2来做。下面话不多说了&#xff0c;来一起看看…

2021-09-23

1、【Python标准库之字符串处理库、文件及目录操作、时间日期】知识点机构图链接&#xff1a;https://pan.baidu.com/s/1E1jyB4u9aIbPxYJzWt401g 提取码&#xff1a;88762、【Python模块、包、文件、异常、高阶函数】高清知识点机构图链接&#xff1a;https://pan.baidu.com/s/…