Python 将图像转换为字符串时出现PyteSeract错误

Python 将图像转换为字符串时出现PyteSeract错误,python,pytesser,Python,Pytesser,我不断收到以下代码的错误: import pytesseract from PIL import Image, ImageEnhance, ImageFilter im = Image.open("book.jpg") # the second one im = im.filter(ImageFilter.MedianFilter()) enhancer = ImageEnhance.Contrast(im) im = enhancer.enhance(2) im = im.convert('

我不断收到以下代码的错误:

import pytesseract
from PIL import Image, ImageEnhance, ImageFilter

im = Image.open("book.jpg") # the second one
im = im.filter(ImageFilter.MedianFilter())
enhancer = ImageEnhance.Contrast(im)
im = enhancer.enhance(2)
im = im.convert('1')
text = pytesseract.image_to_string(im)
print text
错误是:

文件“demo2.py”,第9行,在
text=pytesseract.image\u to\u字符串(im)
文件“/home/vagrant/src/env/local/lib/python2.7/site packages/pytesseract/pytesseract.py”,第161行,在图像字符串中
config=config)
文件“/home/vagrant/src/env/local/lib/python2.7/site packages/pytesseract/pytesseract.py”,第94行,在run_tesseract中
stderr=子流程(管道)
文件“/usr/lib/python2.7/subprocess.py”,第711行,在__
错误读取,错误写入)
文件“/usr/lib/python2.7/subprocess.py”,第1343行,在执行子进程中
引发子对象异常
OSError:[Errno 2]没有这样的文件或目录
我不确定这是安装问题还是其他问题。
我读了的答案,但它们对我没有帮助。

我也有同样的问题,但我成功地将图像转换为字符串。 使用
apt-get
应该可以做到以下几点:

sudo apt-get install tesseract-ocr
如果不能在python脚本中使用它,请执行以下操作:

from os import system

system("tesseract -l eng /image.png text.txt")

现在可以使用了吗?对于macos,
tesseract
可用于
brew安装tesseract