简体   繁体   English

没有名为“ Ocr”的模块

[英]No Module Named 'Ocr'

Working on an OCR. 在OCR上工作。 I can import asprise_ocr_api and I want to work on this: 我可以导入asprise_ocr_api,我想做这个:

from asprise_ocr_api import *
Ocr.set_up()
ocrEngine = Ocr()
ocrEngine.start_engine("eng")
s = ocrEngine.recognize("1.png", -1, -1, -1, -1, -1,
OCR_RECOGNIZE_TYPE_ALL, OCR_OUTPUT_FORMAT_PLAINTEXT)
print("Result: " + s)
ocrEngine.stop_engine()

becasuse the code fail: 因为代码失败:

OUTPUT: OUTPUT:

 File "C:\Users\hp\PycharmProjects\KOFAI(Knight Online Arfiitical ^ 
 Intelligince\MNIST.py", line 1, in <module>
 from asprise_ocr_api import *
 File "C:\Users\hp\AppData\Local\Programs\Python\Python36\lib\site-
 packages\asprise_ocr_api\__init__.py", line 1, in <module>
 from ocr import *
 ModuleNotFoundError: No module named 'ocr'

I keep getting this error. 我不断收到此错误。 I Need Help :) 我需要帮助 :)

Try this: 尝试这个:

easy_install tinyocr

Or 要么

pip install tinyocr

Or, follow the docs . 或者,按照docs进行操作

The asprise_ocr_api module doesn't do submodule imports correctly in Python 3. asprise_ocr_api模块在Python 3中无法正确导入子模块。

For example __init__.py contains from ocr import * . 例如__init__.py包含from ocr import * For a sub-module in Python 3 that should be from .ocr import * . 对于Python 3中的子模块,它应该from .ocr import * Idem for from ocr_app import OcrApp, run_ocr_app . from ocr_app import OcrApp, run_ocr_app That should be from .ocr_app import OcrApp, run_ocr_app . 那应该是from .ocr_app import OcrApp, run_ocr_app

After making these changes in all files it imports correctly. 在所有文件中进行这些更改后,它可以正确导入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM