Error using pytesseract

微笑、不失礼 提交于 2019-12-11 10:42:45

问题


I am using pytesseract to convert images to text. I successfully installed pytesseract with pip command. But when i run the script, it shows me error : No module named Tesseract.

These are my codes :

from tesseract import image_to_string
image = Image.open('input-NEAREST.tif')
print image_to_string(image)

Error :

Traceback (most recent call last):
  File "C:\Users\J's MAgic\Desktop\py\new1.py", line 1, in <module>
    from tesseract import image_to_string
ImportError: No module named tesseract

回答1:



from PIL import Image
import pytesseract as tess

print tess.image_to_string(Image.open('3.png'), lang='tur')

Try this




回答2:


It should be not from tesseract import image_to_string, but from pytesseract import image_to_string. Also, there are some problems with pip installation of pytesseract and lack of documentation of how properly install pytesseract, and I believe you will receive error when you will run your code. If you will be able to run your program that's great, but if you will receive error, do following: Download "tesseract-ocr-setup-3.02.02.exe" file from Sourceforge tesseract-ocr page and install it simply running .exe file in some specific folder. After, add this folder to your PATH environment. Then try to run your program.



来源:https://stackoverflow.com/questions/29873886/error-using-pytesseract

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!