我正在尝试运行:
from PIL import Image
import pytesseract
im = Image.open("sample1.jpg")
test = pytesseract.image_to_string(im, lang='eng')
print(text)
并且正在我的Mac上接收它:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pytesseract/pytesseract.py", line 170, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args())
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.5/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'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/abhishekagarwal/Desktop/OCR_testing.py", line 6, in <module>
test = pytesseract.image_to_string(im, lang='eng')
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pytesseract/pytesseract.py", line 294, in image_to_string
return run_and_get_output(*args)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pytesseract/pytesseract.py", line 202, in run_and_get_output
run_tesseract(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pytesseract/pytesseract.py", line 172, in run_tesseract
raise TesseractNotFoundError()
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path
我可能找到了更改目录的Windows解决方案:请告诉我它在Mac上的等效功能。
pytesseract.pytesseract.tesseract_cmd = '<full_path_to_your_tesseract_executable>'
另外我还尝试了所有其他重新安装自制软件,xcode,sudo的东西。