import pytesseract
from PIL import Image
img = Image.open('image1.jpg')
result = pytesseract.image_to_string(img)
print(result)
My question is may similar to this and this . But, there's no helpful answer for me...
Error:
Traceback (most recent call last):
File "/home/istiak/PycharmProjects/image-to-text/venv/lib64/python3.9/site-packages/pytesseract/pytesseract.py", line 255, in run_tesseract proc = subprocess.Popen(cmd_args, **subprocess_args()) File "/usr/lib64/python3.9/subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib64/python3.9/subprocess.py", line 1823, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'tesseract'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/istiak/PycharmProjects/image-to-text/main.py", line 6, in result = pytesseract.image_to_string(img) File "/home/istiak/PycharmProjects/image-to-text/venv/lib64/python3.9/site-packages/pytesseract/pytesseract.py", line 409, in image_to_string return { File "/home/istiak/PycharmProjects/image-to-text/venv/lib64/python3.9/site-packages/pytesseract/pytesseract.py", line 412, in Output.STRING: lambda: run_and_get_output(*args), File "/home/istiak/PycharmProjects/image-to-text/venv/lib64/python3.9/site-packages/pytesseract/pytesseract.py", line 287, in run_and_get_output run_tesseract(**kwargs) File "/home/istiak/PycharmProjects/image-to-text/venv/lib64/python3.9/site-packages/pytesseract/pytesseract.py", line 259, in run_tesseract raise TesseractNotFoundError() pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your PATH. See README file for more information.
But, I have pytesseract right there..
I found this helpful for him . But, I am using Linux Fedora... Is there something just like this in Linux?
I tried to install tesseract-ocr
link ......
sudo snap install tesseract-ocr
sudo dnf install tesseract-ocr
Error: Unable to find a match: tesseract-ocr
I am facing similar issue I am using command prompt
I installed tesseract here
(venv) C:\Users\user1\Documents\python\OCR>pip install tesseract
Collecting tesseract
Downloading tesseract-0.1.3.tar.gz (45.6 MB)
---------------------------------------- 45.6/45.6 MB 26.2 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Installing collected packages: tesseract
DEPRECATION: tesseract is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
Running setup.py install for tesseract ... done
Successfully installed tesseract-0.1.3
executed the code here:
(venv) C:\Users\user1\Documents\python\OCR>python ocr-pytesseract.py
Traceback (most recent call last):
File "C:\Users\user1\Documents\python\OCR\venv\lib\site-packages\pytesseract\pytesseract.py", line 255, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args())
File "C:\Users\user1\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\user1\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\user1\Documents\python\OCR\ocr-pytesseract.py", line 8, in <module>
text = pytesseract.image_to_string(image)
File "C:\Users\user1\Documents\python\OCR\venv\lib\site-packages\pytesseract\pytesseract.py", line 423, in image_to_string
return {
File "C:\Users\user1\Documents\python\OCR\venv\lib\site-packages\pytesseract\pytesseract.py", line 426, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "C:\Users\user1\Documents\python\OCR\venv\lib\site-packages\pytesseract\pytesseract.py", line 288, in run_and_get_output
run_tesseract(**kwargs)
File "C:\Users\user1\Documents\python\OCR\venv\lib\site-packages\pytesseract\pytesseract.py", line 260, in run_tesseract
raise TesseractNotFoundError()
**pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your PATH.** See README file for more information.
Tesseract is already installed:
(venv) C:\Users\user1\Documents\python\OCR>pip install tesseract
Requirement already satisfied: tesseract in c:\users\user1\documents\python\ocr\venv\lib\site-packages (0.1.3)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.