如何在ubuntu中从图像python获取文本

如何在ubuntu中从图像python获取文本,python,tesseract,Python,Tesseract,我想从图像中读取文本,并在Python中使用PyteSeract。运行代码时: ` # Recognize the text as string in image using pytesserct text.append(str(pytesseract.image_to_string(Image.open(imagefilename), encoding='utf-8', errors="Error"))) #Finally, wri

我想从图像中读取文本,并在Python中使用PyteSeract。运行代码时:

`   


        # Recognize the text as string in image using pytesserct 
        text.append(str(pytesseract.image_to_string(Image.open(imagefilename), encoding='utf-8', errors="Error")))
         #Finally, write the processed text to the file. 
    f.write(" ".join(text)) 

    # Close the file after writing all the text. 
    f.close()
    break`
这就是错误:

    File "/home/doc/desktop/lettura_pdf.py", line 87, in <module>
    text.append(str(pytesseract.image_to_string(Image.open(imagefilename), encoding='utf-8', errors="Error")))
TypeError: image_to_string() got an unexpected keyword argument 'encoding'
文件“/home/doc/desktop/lettura_pdf.py”,第87行,在
text.append(str(pytesseract.image_to_字符串(image.open(imagefilename),encoding='utf-8',errors=“Error”))
TypeError:image\u to\u string()获得意外的关键字参数“encoding”
此处:

   f = open(txtfile, "w") 
    text = []
    # Iterate from 1 to total number of pages 
    for i in range(1, filelimit + 1): 

        # Set filename to recognize text from 
        # Again, these files will be: 
        # page_1.jpg 
        # page_2.jpg 
        # .... 
        # page_n.jpg 
        imagefilename = folder+"/page_"+str(i)+".jpg"

        # Recognize the text as string in image using pytesserct 
        text.append(str(pytesseract.image_to_string(Image.open(imagefilename)),encoding='utf-8',errors="Error"))
         #Finally, write the processed text to the file. 
    f.write(" ".join(text)) 

    # Close the file after writing all the text. 
    f.close()
    break

看起来它不像“encoding”参数。检查函数文档语法为“str(object,encoding=encoding,errors=errors)”可以,但您正在将
encoding
参数传递给
image\u to_str()
函数。然后验证您的“()”。完成,但我有以下错误消息TypeError:str()最多接受1个参数(给定3个)来显示更新的代码