pytesseract OCR python 错误 - 示例代码
pytesseract OCR python error - example code
嗨,我试着学习如何使用 pytesseract(https://pypi.python.org/pypi/pytesseract) 所以我 运行 示例代码:
try:
import Image
except ImportError:
from PIL import Image
import pytesseract
im=Image.open('test.png')
print(pytesseract.image_to_string(im))
但是我有错误:
Traceback (most recent call last):
File "C:/Users/K/PycharmProjects/untitled/zad1.py", line 7, in <module>
print(pytesseract.image_to_string(im))
File "C:\Users\K\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pytesseract-0.1.6-py3.5.egg\pytesseract\pytesseract.py", line 161, in image_to_string
File "C:\Users\K\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pytesseract-0.1.6-py3.5.egg\pytesseract\pytesseract.py", line 94, in run_tesseract
File "C:\Users\K\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "C:\Users\K\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1220, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
我的python版本是3.5,pytesseract版本是0.1.6。
我在 windows 7.
上工作
我解决我的problem.Solution其实很简单:
安装 tesseract-ocr.
我的 Ubuntu 也遇到了这个问题。感谢@Newbie,安装tesseract后解决了
sudo apt-get install tesseract-ocr
sudo apt-get install tesseract-ocr-chi-sim
好像
sudo pip install pytesseract
只安装 python 接口而不是 tesseract 本身
以下是我的错误信息:
OSError Traceback (most recent call last)
<ipython-input-4-aaddc46c52ee> in <module>()
----> 1 pytesseract.image_to_string(Image.open('./static/files/captcha'))
/usr/local/lib/python2.7/dist-packages/pytesseract/pytesseract.pyc in image_to_string(image, lang, boxes, config)
159 lang=lang,
160 boxes=boxes,
--> 161 config=config)
162 if status:
163 errors = get_errors(error_string)
/usr/local/lib/python2.7/dist-packages/pytesseract/pytesseract.pyc in run_tesseract(input_filename, output_filename_base, lang, boxes, config)
92
93 proc = subprocess.Popen(command,
---> 94 stderr=subprocess.PIPE)
95 return (proc.wait(), proc.stderr.read())
96
/usr/lib/python2.7/subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
708 p2cread, p2cwrite,
709 c2pread, c2pwrite,
--> 710 errread, errwrite)
711 except Exception:
712 # Preserve original exception in case os.close raises.
/usr/lib/python2.7/subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
1333 raise
1334 child_exception = pickle.loads(data)
-> 1335 raise child_exception
1336
1337
OSError: [Errno 2] No such file or directory
嗨,我试着学习如何使用 pytesseract(https://pypi.python.org/pypi/pytesseract) 所以我 运行 示例代码:
try:
import Image
except ImportError:
from PIL import Image
import pytesseract
im=Image.open('test.png')
print(pytesseract.image_to_string(im))
但是我有错误:
Traceback (most recent call last):
File "C:/Users/K/PycharmProjects/untitled/zad1.py", line 7, in <module>
print(pytesseract.image_to_string(im))
File "C:\Users\K\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pytesseract-0.1.6-py3.5.egg\pytesseract\pytesseract.py", line 161, in image_to_string
File "C:\Users\K\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pytesseract-0.1.6-py3.5.egg\pytesseract\pytesseract.py", line 94, in run_tesseract
File "C:\Users\K\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "C:\Users\K\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1220, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
我的python版本是3.5,pytesseract版本是0.1.6。 我在 windows 7.
上工作我解决我的problem.Solution其实很简单: 安装 tesseract-ocr.
我的 Ubuntu 也遇到了这个问题。感谢@Newbie,安装tesseract后解决了
sudo apt-get install tesseract-ocr
sudo apt-get install tesseract-ocr-chi-sim
好像
sudo pip install pytesseract
只安装 python 接口而不是 tesseract 本身
以下是我的错误信息:
OSError Traceback (most recent call last)
<ipython-input-4-aaddc46c52ee> in <module>()
----> 1 pytesseract.image_to_string(Image.open('./static/files/captcha'))
/usr/local/lib/python2.7/dist-packages/pytesseract/pytesseract.pyc in image_to_string(image, lang, boxes, config)
159 lang=lang,
160 boxes=boxes,
--> 161 config=config)
162 if status:
163 errors = get_errors(error_string)
/usr/local/lib/python2.7/dist-packages/pytesseract/pytesseract.pyc in run_tesseract(input_filename, output_filename_base, lang, boxes, config)
92
93 proc = subprocess.Popen(command,
---> 94 stderr=subprocess.PIPE)
95 return (proc.wait(), proc.stderr.read())
96
/usr/lib/python2.7/subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
708 p2cread, p2cwrite,
709 c2pread, c2pwrite,
--> 710 errread, errwrite)
711 except Exception:
712 # Preserve original exception in case os.close raises.
/usr/lib/python2.7/subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
1333 raise
1334 child_exception = pickle.loads(data)
-> 1335 raise child_exception
1336
1337
OSError: [Errno 2] No such file or directory