本文介绍: 安装 lanms 库,巨难装,拒绝任何花里胡哨,十分钟,三步内解决问题

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

pip 下载报错

Keyring is skipped due to an exception: 'keyring.backends'
Collecting lanms
  Using cached lanms-1.0.2.tar.gz (973 kB)
    ERROR: Command errored out with exit status 1:
     command: 'C:UsersTensorFlowanaconda3python.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('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:UsersTENSOR~1AppDataLocalTemppip-install-46p1kew5lanmspip-egg-info'
         cwd: C:UsersTENSOR~1AppDataLocalTemppip-install-46p1kew5lanms
    Complete output (11 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:UsersTENSOR~1AppDataLocalTemppip-install-46p1kew5lanmssetup.py", line 27, in <module>
        if subprocess.call(['make', '--always-make','-C', BASE_DIR]) != 0:
      File "C:UsersTensorFlowanaconda3libsubprocess.py", line 339, in call
        with Popen(*popenargs, **kwargs) as p:
      File "C:UsersTensorFlowanaconda3libsubprocess.py", line 800, in __init__
        restore_signals, start_new_session)
      File "C:UsersTensorFlowanaconda3libsubprocess.py", line 1207, in _execute_child
        startupinfo)
    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:UsersTensorFlowanaconda3libsubprocess.py", line 339, in call
    with Popen(*popenargs, **kwargs) as p:
  File "C:UsersTensorFlowanaconda3libsubprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "C:UsersTensorFlowanaconda3libsubprocess.py", line 1207, in _execute_child
    startupinfo)
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 PaddleOCR
  File "D:study配料表分析PaddleOCR-release-2.6paddleocr.py", line 34, in <module>
    from tools.infer import predict_system
  File "D:study配料表分析PaddleOCR-release-2.6toolsinferpredict_system.py", line 33, in <module>
    import tools.infer.predict_det as predict_det
  File "D:study配料表分析PaddleOCR-release-2.6toolsinferpredict_det.py", line 31, in <module>
    from ppocr.data import create_operators, transform
  File "D:study配料表分析PaddleOCR-release-2.6ppocrdata__init__.py", line 35, in <module>
    from ppocr.data.imaug import transform, create_operators
  File "D:study配料表分析PaddleOCR-release-2.6ppocrdataimaug__init__.py", line 48, in <module>
    from .drrg_targets import DRRGTargets
  File "D:study配料表分析PaddleOCR-release-2.6ppocrdataimaugdrrg_targets.py", line 21, in <module>
    from lanms import merge_quadrangle_n9 as la_nms
  File "C:UsersTensorFlowanaconda3envsAIlibsite-packageslanms__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 np


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

如果还有其他问题可以留言

原文地址:https://blog.csdn.net/weixin_44354483/article/details/129415169

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_15851.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注