Search code examples
pythonpipcondapaddle-paddle

Problem at calling module paddleocr in Python with Anaconda


Good morning, I have been trying to install paddleOCR(https://github.com/PaddlePaddle/PaddleOCR) with anaconda and I tried to start it with the command line at cmd and it works fine:

(paddle_env) C:\OCR>paddleocr --image_dir source/test.png --use_angle_cls true --lang en

But when I try to do it by code:

from paddleocr import PaddleOCR,draw_ocr
ocr = PaddleOCR(use_angle_cls=True, lang='en') # need to run only once to download and load model into memory
img_path = './source/test.jpg'
result = ocr.ocr(img_path, cls=True)
for line in result:
    print(line)

I get the next error like if the library of paddle was not installed but it is. So I'm not guessing which is the error:

  File "C:\OCR\required\ocr.py", line 1, in <module>
    from paddleocr import PaddleOCR,draw_ocr
ModuleNotFoundError: No module named 'paddleocr'

In both executions I'm using the same env.

Thank you for your help.


Solution

  • Try this prompt command:

    pip install "paddleocr>=2.0.1"

    Link to documentation: https://pypi.org/project/paddleocr/