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:\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 call
with 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_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:\Users\TensorFlow\anaconda3\lib\subprocess.py", line 339, in call
with 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_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.6\paddleocr.py", line 34, in <module>
from tools.infer import predict_system
File "D:\study\配料表分析\PaddleOCR-release-2.6\tools\infer\predict_system.py", line 33, in <module>
import tools.infer.predict_det as predict_det
File "D:\study\配料表分析\PaddleOCR-release-2.6\tools\infer\predict_det.py", line 31, in <module>
from ppocr.data import create_operators, transform
File "D:\study\配料表分析\PaddleOCR-release-2.6\ppocr\data\__init__.py", line 35, in <module>
from ppocr.data.imaug import transform, create_operators
File "D:\study\配料表分析\PaddleOCR-release-2.6\ppocr\data\imaug\__init__.py", line 48, in <module>
from .drrg_targets import DRRGTargets
File "D:\study\配料表分析\PaddleOCR-release-2.6\ppocr\data\imaug\drrg_targets.py", line 21, in <module>
from lanms import merge_quadrangle_n9 as la_nms
File "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 文件下的代码。文章来源:https://www.toymoban.com/news/detail-434184.html
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://www.toymoban.com/news/detail-434184.html
到了这里,关于paddleocr,windows pip 安装巨坑 lanms 库,全网最简单,最直接,最有效(记录贴)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!