Python FileNotFoundError:[Errno 2]没有这样的文件或目录:';tesseract';

Python FileNotFoundError:[Errno 2]没有这样的文件或目录:';tesseract';,python,image-processing,ocr,Python,Image Processing,Ocr,我已使用安装了tasseract pip install pytesseract 每当我试图运行这段代码时 from PIL import Image import pytesseract im = Image.open('hasan1.jpg') print (pytesseract.image_to_string(im)) 我犯了这些错误 Traceback (most recent call last): File "ocr.py", line 34, in <module&

我已使用安装了tasseract

pip install pytesseract
每当我试图运行这段代码时

from PIL import Image
import pytesseract
im = Image.open('hasan1.jpg')
print (pytesseract.image_to_string(im))
我犯了这些错误

 Traceback (most recent call last):
 File "ocr.py", line 34, in <module>
 text = pytesseract.image_to_string(Image.open(filename))
 File "/home/hasans/.virtualenvs/cv/local/lib/python3.5/site-
 packages/pytesseract/pytesseract.py", line 193, in image_to_string
 return run_and_get_output(image, 'txt', lang, config, nice)
 File "/home/hasans/.virtualenvs/cv/local/lib/python3.5/site-
 packages/pytesseract/pytesseract.py", line 140, in run_and_get_output
 run_tesseract(**kwargs)
 File "/home/hasans/.virtualenvs/cv/local/lib/python3.5/site-
 packages/pytesseract/pytesseract.py", line 111, in run_tesseract
 proc = subprocess.Popen(command, stderr=subprocess.PIPE)
 File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
 restore_signals, start_new_session)
 File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
 raise child_exception_type(errno_num, err_msg)
 FileNotFoundError: [Errno 2] No such file or directory: 'tesseract'
回溯(最近一次呼叫最后一次):
文件“ocr.py”,第34行,在
text=pytesseract.image_to_字符串(image.open(文件名))
文件“/home/hasans/.virtualenvs/cv/local/lib/python3.5/site-
packages/pytesseract/pytesseract.py”,第193行,在图像_到_字符串中
返回run_和get_输出(图像,'txt',lang,config,nice)
文件“/home/hasans/.virtualenvs/cv/local/lib/python3.5/site-
packages/pytesseract/pytesseract.py”,第140行,在运行和获取输出中
运行_tesseract(**kwargs)
文件“/home/hasans/.virtualenvs/cv/local/lib/python3.5/site-
程序包/pytesseract/pytesseract.py”,第111行,运行中
proc=subprocess.Popen(命令,stderr=subprocess.PIPE)
文件“/usr/lib/python3.5/subprocess.py”,第947行,在__
恢复信号,启动新会话)
文件“/usr/lib/python3.5/subprocess.py”,第1551行,在执行子进程中
引发子项异常类型(errno\u num、err\u msg)
FileNotFoundError:[Errno 2]没有这样的文件或目录:“tesseract”

我相信PyTesseract要求您在系统上安装tesseract库-PyTesseract正在尝试运行命令行界面,但它可能找不到,因为您只安装了python绑定

如果您使用的是基于Ubuntu/Debian的系统,您可以尝试:

sudo apt get安装tesseract ocr


您可以查看Tesseract安装文档以了解更多信息:

关于此主题有很多问题。。。你尝试过什么但没有成功。。。并解释为什么它不起作用。