【问题标题】:Python 2.7 PyTesseract AttributeError: 'PixelAccess' object has no attribute 'split'Python 2.7 PyTesseract AttributeError:“PixelAccess”对象没有属性“split”
【发布时间】:2016-11-18 03:43:22
【问题描述】:
Traceback (most recent call last):
  File "C:\Python27\Stuff\imagetotext.py", line 9, in <module>
    i = pytesseract.image_to_string(img)
  File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 143, in
image_to_string
    if len(image.split()) == 4:
AttributeError: 'PixelAccess' object has no attribute 'split'

所以,我真的不知道该怎么办。 https://gyazo.com/63c6439285d629c72e9076c1b4a29a42 是 test.png。我已经尝试了很多。

try:
    import Image
except ImportError:
    from PIL import Image
import pytesseract

img = Image.open('test.bmp').load()
#img.load()
i = pytesseract.image_to_string(img)
print i

我读过它可能是 PIL 的一个错误,但我不知道。

【问题讨论】:

    标签: python ocr pytesser


    【解决方案1】:
    try:
        import Image
    except ImportError:
        from PIL import Image
    import pytesseract
    
    img = Image.open('test.bmp')
    img.load()
    i = pytesseract.image_to_string(img)
    print i
    

    【讨论】:

    • WindowsError: [错误2] 系统找不到指定的文件
    • 它在同一个文件夹中。
    • 我认为你没有安装 tesseract。
    • 我愿意,它可以正常导入。
    • 我不是在说 pytesseract,它只是一个包装器。您需要在系统中安装 tesseract。如果 tesseract 存在,你可以检查你的命令行吗?比如“tesseract image.tif image”
    猜你喜欢
    • 2016-09-11
    • 1970-01-01
    • 1970-01-01
    • 2021-04-05
    • 2017-07-02
    • 2016-01-31
    • 2016-09-19
    • 2020-09-14
    • 2021-07-25
    相关资源
    最近更新 更多