So I have been working on this problem for awhile and while others have had questions similar to this but nothing has worked for me:
I am trying to use pytesseract for a project and I have it installed under User/Environments/testEnv/lib/python3.6/site-packages/pytesseract/
I have tesseract installed under usr/local/bin
I have gone into Users/User/Environments/testEnv/lib/python3.6/site-packages/pytesseract/pytesseract.py
and changed tesseract_cmd = 'tesseract'
to tesseract_cmd = '/usr/local/bin/tesseract'
as suggested here: OSError: [Errno 2] No such file or directory using pytesser
This did not work. I tried to run this:
try:
import Image
except ImportError:
from PIL import Image
import pytesseract
img = Image.open('screenshot.png')
img.load()
i = pytesseract.image_to_string(img)
print (i)
and I get this:
Traceback (most recent call last):
File "/Users/User/Environments/testEnv/testTess.py", line 26, in <module>
i = pytesseract.image_to_string(img)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pytesseract/pytesseract.py", line 122, in image_to_string
config=config)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pytesseract/pytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tesseract': 'tesseract'
This is telling me that tesseract can't be found even though I specified in pytesseract.py
. This befuddles me.
Note: You can probably tell but I am using a virtualenv - could this be an issue due to the fact that tesseract is not in the environment but pytesseract is?
I am using mac osx and python3.6.
I am new to coding and I simply cannot find a solution to this issue.
Thanks!
UPDATE: I have now re-downloaded tesseract and tried this again and also tried putting tesseract here: /Users/User/Environments/testEnv/bin/tesseract/3.05.01/bin/tesseract
so that is is within the environment in case that was an issue.
I still cannot make anything work! Absolutely any suggestions would help.
FINAL UPDATE: I gave up on the environment and deleted it and program worked.