PaddleOCR安装记录【ERROR: Failed building wheel for lanms-neo Failed to build lanms-neo】

PaddleOCR安装记录

项目地址

1、“环境准备”

1.创建conda环境

conda create --name paddle_env python=3.8 --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ 

2.激活paddle_env

conda activate paddle_env

3.安装PaddlePaddle

python -m pip install paddlepaddle-gpu -i https://pypi.tuna.tsinghua.edu.cn/simple

官方给的这种安装方式有坑,如果你已经按照过cuda可能会不匹配。去这里根据自己的cuda版本下载paddlepaddle https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/windows-pip.html

4.安装PaddleOCR Whl Package

pip install "paddleocr>=2.0.1"

2、“项目克隆”

1.克隆 PaddleOCR项目

git clone https://github.com/PaddlePaddle/PaddleOCR

2.安装第三方依赖

cd PaddleOCR
pip3 install -r requirements.txt

3、PaddleOCR 快速入门

命令行使用

PaddleOCR提供了一系列测试图片,点击这里下载,然后在终端切换到对应目录

cd /path/to/ppocr_img
paddleocr --image_dir ./imgs_en/img_12.jpg --use_angle_cls true --lang en --use_gpu false

(无语了,本来用命令行还可以的,运行忘记截图了。然后用代码使用出现error解决后用命令行报 ==module ‘numpy’ has no attribute ‘int’.==错误了)

按代码使用

把下载的一系列测试图片放到项目根目录

demo.py

from paddleocr import PaddleOCR,draw_ocr
# Paddleocr supports Chinese, English, French, German, Korean and Japanese.
# You can set the parameter `lang` as `ch`, `en`, `fr`, `german`, `korean`, `japan`
# to switch the language model in order.
ocr = PaddleOCR(use_angle_cls=True, lang='en') # need to run only once to download and load model into memory
img_path = './ppocr_img/imgs_en/img_12.jpg'
result = ocr.ocr(img_path, cls=True)
for idx in range(len(result)):
    res = result[idx]
    for line in res:
        print(line)


# draw result
from PIL import Image
result = result[0]
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, font_path='./fonts/simfang.ttf')
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')

PaddleOCR安装记录【ERROR: Failed building wheel for lanms-neo Failed to build lanms-neo】_第1张图片

ERROR1

pip3 install -r requirements.txt时报错

“C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe” /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\86151\AppData\Local\Temp\pip-install-h7lum1d5\lanms-neo_
3c3dd20b1e2245fbbf6f5f6c093bf137\lanms\csrc -IC:\Users\86151\AppData\Local\Temp\pip-build-env-3x3cmi7z\overlay\Lib\site-packages\pybind11\include -IF:\miniconda3\envs\paddle_env\include -
IF:\miniconda3\envs\paddle_env\Include “-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt” “-IC:\Progra
m Files (x86)\Windows Kits\8.1\include\shared” “-IC:\Program Files (x86)\Windows Kits\8.1\include\um” “-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt” “-IC:\Program Files (x86)\M
icrosoft Visual Studio 14.0\VC\include” “-IC:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt” /EHsc /Tplanms/csrc/clipper\clipper.cpp /Fobuild\temp.win-amd64-cpython-38\Rel
ease\lanms/csrc/clipper\clipper.obj /std:c++latest /EHsc /bigobj
clipper.cpp
lanms/csrc/clipper\clipper.cpp(3795): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prev
ent data loss
“C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe” /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\86151\AppData\Local\Temp\pip-install-h7lum1d5\lanms-neo_
3c3dd20b1e2245fbbf6f5f6c093bf137\lanms\csrc -IC:\Users\86151\AppData\Local\Temp\pip-build-env-3x3cmi7z\overlay\Lib\site-packages\pybind11\include -IF:\miniconda3\envs\paddle_env\include -
IF:\miniconda3\envs\paddle_env\Include “-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt” “-IC:\Progra
m Files (x86)\Windows Kits\8.1\include\shared” “-IC:\Program Files (x86)\Windows Kits\8.1\include\um” “-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt” “-IC:\Program Files (x86)\M
icrosoft Visual Studio 14.0\VC\include” “-IC:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt” /EHsc /Tplanms/csrc\lanms.cpp /Fobuild\temp.win-amd64-cpython-38\Release\lanms
/csrc\lanms.obj /std:c++latest /EHsc /bigobj
lanms.cpp
c:\users\86151\appdata\local\temp\pip-build-env-3x3cmi7z\overlay\lib\site-packages\pybind11\include\pybind11\detail/common.h(147): fatal error C1189: #error: pybind11 2.10+ require
s MSVC 2017 or newer
error: command ‘C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe’ failed with exit code 2
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for lanms-neo
Failed to build lanms-neo
ERROR: Could not build wheels for lanms-neo, which is required to install pyproject.toml-based projects

PaddleOCR安装记录【ERROR: Failed building wheel for lanms-neo Failed to build lanms-neo】_第2张图片

注意一下报错标高亮的部分,网上搜了一下好像也是说因为Microsoft Visual C++版本的问题

answer1

answer2

这里升级了一下Visual Studio到2022版本

PaddleOCR安装记录【ERROR: Failed building wheel for lanms-neo Failed to build lanms-neo】_第3张图片

安装完成后直接重新安装依赖,问题解决!

PaddleOCR安装记录【ERROR: Failed building wheel for lanms-neo Failed to build lanms-neo】_第4张图片

ERROR2

代码使用时报错,原因是cuda版本和安装的paddlepaddle-gpu版本不匹配。官方给的实例应该是和cuda 10.1/10.2匹配的

PaddleOCR安装记录【ERROR: Failed building wheel for lanms-neo Failed to build lanms-neo】_第5张图片

answer

PaddlePaddle 环境要求是 CUDA Runtime Version
在文档中,描述安装 GPU 版 PaddlePaddle 的环境要求如下:

CUDA 工具包 10.2 配合 cuDNN v7.6.5,如需使用 PaddleTensorRT 推理,需配合 TensorRT7.0.0.11
CUDA 工具包 11.2 配合 cuDNN v8.2.1,如需使用 PaddleTensorRT 推理,需配合 TensorRT8.2.4.2
CUDA 工具包 11.6 配合 cuDNN v8.4.0,如需使用 PaddleTensorRT 推理,需配合 TensorRT8.4.0.6
CUDA 工具包 11.7 配合 cuDNN v8.4.1,如需使用 PaddleTensorRT 推理,需配合 TensorRT8.4.2.4
GPU 运算能力超过 3.5 的硬件设备

PaddlePaddle 文档地址:

不同版本的cuda安装不同版本的paddlepaddle-gpu

PaddleOCR安装记录【ERROR: Failed building wheel for lanms-neo Failed to build lanms-neo】_第6张图片

重新安装后,运行按代码使用的demo.py

你可能感兴趣的:(python,深度学习,开发语言)