Search code examples
pythonocrpaddle-paddlepaddleocr

ImportError: cannot import name 'inference' from 'paddle'


I am trying to implement paddleocr. I have installed it using:

#Github repo installation for paddle
! python3 -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple

#install paddle ocr
!pip install paddleocr

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

But while importing

from paddleocr import PaddleOCR,draw_ocr

I'm getting this error: ImportError: cannot import name 'inference' from 'paddle'


Solution

  • I had the same error. My solution was to:

    pip install paddlepaddle
    

    Then I got another error (luckily you will not get this one but just in case) telling me to downgrade protoc to a version between 3.19 and 3.20, which I fixed by executing the following command:

    pip install protobuf==3.19.0
    

    After this I was able to execute the script that imported from paddleocr