Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'tools.infer' while Detectron2 are installed #13335

Closed
yogi0421 opened this issue Jul 10, 2024 · 6 comments · Fixed by #13348
Closed

ModuleNotFoundError: No module named 'tools.infer' while Detectron2 are installed #13335

yogi0421 opened this issue Jul 10, 2024 · 6 comments · Fixed by #13348

Comments

@yogi0421
Copy link

问题描述 / Problem Description

When I try to import paddleocr, it return ModuleNotFoundError: No module named 'tools.infer', this happened on my environment with Detectron2 are installed.

运行环境 / Runtime Environment

  • OS: Docker - Ubuntu 22.04.2 LTS
  • Paddlepaddle-gpu: 2.6.1
  • PaddleOCR: 2.8.0
  • Detectron2 version : 0.6+864913fpt2.1.2cu121
  • CUDA Version : 12.1

复现代码 / Reproduction Code

from paddleocr import PaddleOCR

完整报错 / Complete Error Message

Python 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from paddleocr import PaddleOCR
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/dist-packages/paddleocr/__init__.py", line 14, in <module>
    from .paddleocr import *
  File "/usr/local/lib/python3.10/dist-packages/paddleocr/paddleocr.py", line 34, in <module>
    from tools.infer import predict_system
ModuleNotFoundError: No module named 'tools.infer'

可能解决方案 / Possible solutions

I manually edit the paddle.py file, on code
from :

from tools.infer import predict_system
from tools.infer.utility import draw_ocr, str2bool, check_gpu

to :

from paddleocr.tools.infer import predict_system
from paddleocr.tools.infer.utility import draw_ocr, str2bool, check_gpu

附件 / Appendix

@yogi0421
Copy link
Author

are this is expected?

@GreatV
Copy link
Collaborator

GreatV commented Jul 10, 2024

You're right, tools is the generic name, it's better to import it with the namespace paddleocr.

@yogi0421
Copy link
Author

@GreatV did you know the release branch that solved this issue?
or this issue are still happen on almost all version of paddleocr?

@GreatV
Copy link
Collaborator

GreatV commented Jul 10, 2024

@yogi0421 This issue is not yet fixed in the release branch.

@myhloli
Copy link
Contributor

myhloli commented Jul 11, 2024

I encountered the same issue, which only occurred in version 2.8.0; there were no problems in version 2.7.3. To resolve it, I replaced tools.infer with paddleocr.tools.infer which fixed the problem.

@myhloli
Copy link
Contributor

myhloli commented Jul 11, 2024

@GreatV I carefully reviewed the differences between versions 2.7.3 and 2.8.0, and found that in 2.8.0, "from tools.infer import predict_system" was placed before the definition of the "tools" methods. This is why the issue did not reproduce on 2.7.3. I have already submitted the fix code at #13348

@GreatV GreatV linked a pull request Jul 11, 2024 that will close this issue
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants