Skip to content

ModuleNotFoundError: No module named 'paddle' #14115

Closed
@Cupcc

Description

@Cupcc

🔎 Search before asking

  • I have searched the PaddleOCR Docs and found no similar bug report.
  • I have searched the PaddleOCR Issues and found no similar bug report.
  • I have searched the PaddleOCR Discussions and found no similar bug report.

🐛 Bug (问题描述)

https://paddlepaddle.github.io/PaddleOCR/latest/quick_start.html
按照上述指南操作,报错了
pip install paddleocr

from paddleocr import PaddleOCR,draw_ocr
ocr = PaddleOCR(lang='en') # need to run only once to download and load model into memory
img_path = './images/img.jpg'
result = ocr.ocr(img_path, cls=False)
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='/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf')
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')

error:

File "/home/chris/miniconda3/envs/paddle_ocr/lib/python3.11/site-packages/paddleocr/paddleocr.py", line 21, in <module>
    from paddle.utils import try_import
ModuleNotFoundError: No module named 'paddle'

🏃‍♂️ Environment (运行环境)

python:3.11
paddleocr: 2.9.1
OS: ubuntu 22.04LTS
IDE: pycharm

🌰 Minimal Reproducible Example (最小可复现问题的Demo)

from paddleocr import PaddleOCR,draw_ocr
ocr = PaddleOCR(lang='en') # need to run only once to download and load model into memory
img_path = './images/img.jpg'
result = ocr.ocr(img_path, cls=False)
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='/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf')
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions