PaddleOCRwindows下报错解决方案
PaddleOCR 官方链接 https://github.com/PaddlePaddle/PaddleOCR
运行环境
- Windows 10 操作系统
- Python -version
Python 3.10.11
- pip install paddlepaddle==2.4.2 -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html
- pip install paddleocr==2.7.3
目前paddleocr最新版本是2.7.3
测试代码
# -*- coding: utf-8 -*-
# __ author:Jack
# date: 2024-06-16
from paddleocr import PaddleOCR
import paddle.fluid
paddle.fluid.install_check.run_check()
def show():
ocr = PaddleOCR(use_angle_cls=True, lang="ch")
image_path = f'example.jpg'
result = ocr.ocr(image_path, cls=True)
for idx in range(len(result)):
res = result[idx]
for line in res:
print(line)
if __name__ == '__main__':
show()
抛出异常 numpy.core.multiarray failed to import
RuntimeError: module compiled against ABI version 0x1000009 but this version of numpy is 0x2000000
Traceback (most recent call last):
File "test.py", line 6, in <module>
from paddleocr import PaddleOCR
File "lib\site-packages\paddleocr\__init__.py", line 14, in <module>
from .paddleocr import *
File "lib\site-packages\paddleocr\paddleocr.py", line 25, in <module>
import cv2
File "lib\site-packages\cv2\__init__.py", line 181, in <module>
bootstrap()
File "lib\site-packages\cv2\__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "importlib\__init__.py", line 126, in import_module
if sys.path[0] == BASE_DIR or os.path.realpath(sys.path[0]) == BASE_DIR:
ImportError: numpy.core.multiarray failed to import
解决方案
pip install -U numpy==1.26.4