模块丢失,而尝试导入的模块已经存在

Module missing while the module trying to import is already there

from PIL import Image
from pytesser import *

image_file = 'E:\Downloads\menu.tiff'
im = Image.open(image_file)
text = image_to_string(im)
text = image_file_to_string(image_file)
text = image_file_to_string(image_file, graceful_errors=True)
print ("=====output=======\n")
print (text)

看到错误显示没有找到模块,但是 util 文件在 tesseract 的目录中 itself.I 不知道为什么会显示找不到。

我的问题在 init.py how to import util.py and errors.py

内部非常简单

您正在使用的图书馆似乎已经六年多没有被碰过。不兼容 Python 3.

找另一个图书馆。

此包需要相对导入(参见 PEP328)。

一个解决方案是替换

import util
import errors

来自

from . import util
from . import errors

此更改是在 python 2.5(2006 年 9 月 19 日)中引入的,所以我完全同意@DanielRoseman,您应该寻找另一个库。 例如,您可以在 PyPi or GitHub 上找到 OCR 包。


编辑:更正了模块名称中的拼写错误