没有名为'Ocr'的模块

时间:2017-07-30 21:41:28

标签: python python-3.x ocr

处理OCR。我可以导入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()

因为代码失败了:

输出:

 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'

我一直收到这个错误。我需要帮助:)

3 个答案:

答案 0 :(得分:2)

试试这个:

easy_install tinyocr

pip install tinyocr

或者,请关注docs

答案 1 :(得分:2)

{3}模块在Python 3中无法正确导入子模块。

例如epg_time_3包含if epg_time_1_months == 1: if epg_time_1_days == 31: epg_time_1_days = 01 epg_time_1_months = 2 elif epg_time_1_months == 2: if epg_time_1_days == 28: epg_time_1_days = 01 epg_time_1_months = 3 elif epg_time_1_months == 3: if epg_time_1_days == 31: epg_time_1_days = 01 epg_time_1_months = 4 elif epg_time_1_months == 4: if epg_time_1_days == 30: epg_time_1_days = 01 epg_time_1_months = 5 elif epg_time_1_months == 5: if epg_time_1_days == 31: epg_time_1_days = 01 epg_time_1_months = 6 elif epg_time_1_months == 6: if epg_time_1_days == 30: epg_time_1_days = 01 epg_time_1_months = 7 elif epg_time_1_months == 7: if epg_time_1_days == 31: epg_time_1_days = 01 epg_time_1_months = 8 elif epg_time_1_months == 8: if epg_time_1_days == 31: epg_time_1_days = 01 epg_time_1_months = 9 elif epg_time_1_months == 9: if epg_time_1_days == 30: epg_time_1_days = 01 epg_time_1_months = 10 elif epg_time_1_months == 10: if epg_time_1_days == 31: epg_time_1_days = 01 epg_time_1_months = 11 elif epg_time_1_months == 11: if epg_time_1_days == 30: epg_time_1_days = 01 epg_time_1_months = 12 elif epg_time_1_months == 12: if epg_time_1_days == 31: epg_time_1_days = 01 epg_time_1_months = 1 。对于Python 3中应该是asprise_ocr_api的子模块。同意__init__.py。那应该是from ocr import *

在所有文件中进行这些更改后,它会正确导入。

答案 2 :(得分:0)