from PIL import Image
import pytesseract
im = Image.open("news.jpg")
text = pytesseract.image_to_string(im, lang='eng')
print(text)
所以上面的代码抛出了这个错误:
Traceback (most recent call last):
File "C:\Users\test\Documents\Projects\TesseractTest\main.py", line 6, in <module>
text = pytesseract.image_to_string(im, lang='eng')
File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string
config=config)
File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "C:\Python27\lib\subprocess.py", line 711, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 959, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
news.jpg出现了,我在Windows 10上运行它。
谢谢,Ed。