簡體   English   中英

FileNotFoundError:[錯誤2]沒有這樣的文件或目錄:'tesseract'

[英]FileNotFoundError: [Errno 2] No such file or directory: 'tesseract'

我已經使用安裝了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'

我相信PyTesseract要求您在系統上安裝tesseract庫-PyTesseract正在嘗試運行命令行界面,但大概找不到它,因為您僅安裝了python綁定。

如果您使用的是基於Ubuntu / Debian的系統,則可以嘗試:

sudo apt-get install tesseract-ocr

您可以查看Tesseract安裝文檔以獲取更多信息: https : //github.com/tesseract-ocr/tesseract/wiki

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM