错误1:AttributeError: module 'paddle.distributed' has no attribute 'get_rank'
错误2:OSError: [WinError 126] 找不到指定的模块。
错误3。 error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
错误4.AttributeError: module 'paddleocr' has no attribute 'PaddleOCR'
错误5.[2020/12/29 10:51:41] root ERROR: error in loading image:11.jpg(xx图片)
前言
识别时用的代码,注意更改图片地址
博文:PaddleOCR简单使用,识别文字测试
我是用PyCharm IDE
from paddleocr import PaddleOCR, draw_ocr # 模型路径下必须含有model和params文件,如果没有,现在可以自动下载了,不过是最简单的模型 # use_gpu 如果paddle是GPU版本请设置为 True ocr = PaddleOCR(use_angle_cls=True, use_gpu=False) img_path = 'D:/PythonCode/paddle/ocr/11.jpg' # 这个是自己的图片,自行放置在代码目录下修改名称 result = ocr.ocr(img_path, cls=True) for line in result: print(line) # 显示结果 from PIL import Image image = Image.open(img_path).convert('RGB') boxes = [line[0] for line in result] txts = [line[1][0] for line in result] scores = [line[1][1] for line in result] im_show = draw_ocr(image, boxes, txts, scores) im_show = Image.fromarray(im_show) im_show.save('result.jpg') # 结果图片保存在代码同级文件夹中。
错误1:AttributeError: module ‘paddle.distributed’ has no attribute ‘get_rank’
错误3。 error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: https://visualstudio.microsoft.com/visual-cpp-build-tools/
完整错误文本
ERROR: Command errored out with exit status 1: command: ‘d:\code_python\paddle_2\venv\scripts\python.exe’ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"‘C:\Users\mgboy\AppData\Local\Temp\pip-inst all-9t28wbny\python-levenshtein_13c216c123594819b0c3e6a2680b39cc\setup.py’"’"’; file=’"’"‘C:\Users\mgboy\AppData\Local\Temp\pip-install-9t28wbny\python-levensh tein_13c216c123594819b0c3e6a2680b39cc\setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec( compile(code, file, ‘"’"‘exec’"’"’))’ install --record ‘C:\Users\mgboy\AppData\Local\Temp\pip-record-x3h79u3f\install-record.txt’ --single-version-externally-managed – compile --install-headers ‘d:\code_python\paddle_2\venv\include\site\python3.7\python-Levenshtein’ cwd: C:\Users\mgboy\AppData\Local\Temp\pip-install-9t28wbny\python-levenshtein_13c216c123594819b0c3e6a2680b39cc Complete output (27 lines): running install running build running build_py creating build creating build\lib.win-amd64-3.7 creating build\lib.win-amd64-3.7\Levenshtein copying Levenshtein\StringMatcher.py -> build\lib.win-amd64-3.7\Levenshtein copying Levenshtein_init_.py -> build\lib.win-amd64-3.7\Levenshtein running egg_info writing python_Levenshtein.egg-info\PKG-INFO writing dependency_links to python_Levenshtein.egg-info\dependency_links.txt writing entry points to python_Levenshtein.egg-info\entry_points.txt writing namespace_packages to python_Levenshtein.egg-info\namespace_packages.txt writing requirements to python_Levenshtein.egg-info\requires.txt writing top-level names to python_Levenshtein.egg-info\top_level.txt reading manifest file ‘python_Levenshtein.egg-info\SOURCES.txt’ reading manifest template ‘MANIFEST.in’ warning: no previously-included files matching ‘*pyc’ found anywhere in distribution warning: no previously-included files matching ‘*so’ found anywhere in distribution warning: no previously-included files matching ‘.project’ found anywhere in distribution warning: no previously-included files matching ‘.pydevproject’ found anywhere in distribution writing manifest file ‘python_Levenshtein.egg-info\SOURCES.txt’ copying Levenshtein_levenshtein.c -> build\lib.win-amd64-3.7\Levenshtein copying Levenshtein_levenshtein.h -> build\lib.win-amd64-3.7\Levenshtein running build_ext building ‘Levenshtein._levenshtein’ extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: https://visualstudio.microsoft.com/visual-cpp-build-tools/ ---------------------------------------- ERROR: Command errored out with exit status 1: ‘d:\code_python\paddle_2\venv\scripts\python.exe’ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"‘C:\Users\mgbo y\AppData\Local\Temp\pip-install-9t28wbny\python-levenshtein_13c216c123594819b0c3e6a2680b39cc\setup.py’"’"’; file=’"’"‘C:\Users\mgboy\AppData\Local\Temp\pip -install-9t28wbny\python-levenshtein_13c216c123594819b0c3e6a2680b39cc\setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’ “’, '”’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record ‘C:\Users\mgboy\AppData\Local\Temp\pip-record-x3h79u3f\install-record.txt’ --sin gle-version-externally-managed --compile --install-headers ‘d:\code_python\paddle_2\venv\include\site\python3.7\python-Levenshtein’ Check the logs for full command output.
错误5.[2020/12/29 10:51:41] root ERROR: error in loading image:11.jpg(xx图片)
W1229 10:51:40.596693 9548 analysis_predictor.cc:1058] Deprecated. Please use CreatePredictor instead. [2020/12/29 10:51:41] root ERROR: error in loading image:11.jpg Traceback (most recent call last): File “D:/PythonCode/paddle/ocr/testocr.py”, line 8, in for line in result: TypeError: ‘NoneType’ object is not iterable