Python PyteSeract没有此类文件或目录错误

Python PyteSeract没有此类文件或目录错误,python,python-2.7,ubuntu-14.04,Python,Python 2.7,Ubuntu 14.04,我正在使用Ubuntu 14.04。我有以下代码: import Image import pytesseract im = Image.open('test.png') print pytesseract.image_to_string(im) 但我一直得到以下错误: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/d

我正在使用Ubuntu 14.04。我有以下代码:

import Image
import pytesseract
im = Image.open('test.png')
print pytesseract.image_to_string(im)
但我一直得到以下错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 540, in runfile
    execfile(filename, namespace)
  File "/home/chaitanya/pythonapp/localcopy.py", line 4, in <module>
    print pytesseract.image_to_string(im)
  File "/usr/local/lib/python2.7/dist-packages/pytesseract/pytesseract.py", line 142, in image_to_string
    config=config)
  File "/usr/local/lib/python2.7/dist-packages/pytesseract/pytesseract.py", line 75, in run_tesseract
    stderr=subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“/usr/lib/python2.7/dist packages/spyderlib/widgets/externalshell/sitecustomize.py”,第540行,在runfile中
execfile(文件名、命名空间)
文件“/home/chaitanya/pythonapp/localcopy.py”,第4行,在
将PyteSeract.image打印到字符串(im)
文件“/usr/local/lib/python2.7/dist packages/pytesseract/pytesseract.py”,第142行,在图像到字符串中
config=config)
文件“/usr/local/lib/python2.7/dist packages/pytesseract/pytesseract.py”,第75行,在run_tesseract中
stderr=子流程(管道)
文件“/usr/lib/python2.7/subprocess.py”,第710行,在__
错误读取,错误写入)
文件“/usr/lib/python2.7/subprocess.py”,第1327行,在执行子进程中
引发子对象异常
OSError:[Errno 2]没有这样的文件或目录

python程序和映像都位于同一位置。可能有什么问题???

您需要安装
tesseract ocr

sudo apt-get install tesseract-ocr

如果您在windows上安装了PIP,请转到项目目录并运行:


pip安装tesseract ocr

基于@padraic cunningham的答案,该答案是我根据自己的设置定制的

如果您使用Linux(ubuntu 16,应该不重要)并安装了conda:

首先搜索需要安装的内容:

$ anaconda search -t conda tesserocr
您将得到一些选择,您需要查看平台和构建,以确定什么对您有意义

因为我有python 3.6和linux-64,所以我选择了mcs07/tesserocr

要安装:

$ conda install -c mcs07 tesserocr

就这样。我不需要重新启动终端或任何东西。我只是继续前进

我真是太感谢你了!这个错误消息太普通了,我从没想过tesseract会丢失。(对于CentOS:
yum安装tesseract
)对于macOS,您应该运行
brew安装tesseract
。如果未安装brew,请查看以下内容: