简体   繁体   English

使用 pytesseract.image_to_string 时出错

[英]Error while using pytesseract.image_to_string

import cv2
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image 
import pytesseract
pytesseract.pytesseract.tesseract_cmd = "C:\Program Files\Tesseract-OCR"
w1 = cv2.imread('Downloads\ocr4.png')
plt.imshow(w1)
plt.xticks([])
plt.yticks([])
plt.show()

text = pytesseract.image_to_string(w1)
print(text)  

''' its showing this error '''它显示这个错误

~\anaconda3\lib\site-packages\pytesseract\pytesseract.py in run_tesseract(input_filename, output_filename_base, extension, lang, config, nice, timeout) 255 except OSError as e: 256 if e.errno:= ENOENT: --> 257 raise e 258 raise TesseractNotFoundError() 259 ~\anaconda3\lib\site-packages\pytesseract\pytesseract.py in run_tesseract(input_filename, output_filename_base, extension, lang, config, nice, timeout) 255 除了 OSError as e: 256 if e.errno:= ENOENT: --> 257 提高 e 258 提高 TesseractNotFoundError() 259

~\anaconda3\lib\site-packages\pytesseract\pytesseract.py in run_tesseract(input_filename, output_filename_base, extension, lang, config, nice, timeout) 252 253 try: --> 254 proc = subprocess.Popen(cmd_args, **subprocess_args()) 255 except OSError as e: 256 if e.errno:= ENOENT: ~\anaconda3\lib\site-packages\pytesseract\pytesseract.py in run_tesseract(input_filename, output_filename_base, extension, lang, config, nice, timeout) 252 253 try: --> 254 proc = subprocess.Popen(cmd_args, ** subprocess_args()) 255 除了 OSError 为 e: 256 if e.errno:= ENOENT:

~\anaconda3\lib\subprocess.py in init (self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask) 949 encoding=encoding, errors=errors) 950 --> 951 self._execute_child(args, executable, preexec_fn, close_fds, 952 pass_fds, cwd, env, 953 startupinfo, creationflags, shell, ~\anaconda3\lib\subprocess.py in init (self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user,组,extra_groups,编码,错误,文本,umask)949 encoding=encoding,errors=errors)950 --> 951 self._execute_child(args,可执行文件,preexec_fn,close_fds,952 pass_fds,cwd,env,953 startupinfo,creationflags, shell,

~\anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_gid, unused_gids, unused_uid, unused_umask, unused_start_new_session) 1418 # Start the process 1419 try: -> 1420 hp, ht, pid, tid = _winapi.CreateProcess(executable, args, 1421 # no special security 1422 None, None, ~\anaconda3\lib\subprocess.py in _execute_child(self,args,executable,preexec_fn,close_fds,pass_fds,cwd,env,startupinfo,creationflags,shell,p2cread,p2cwrite,c2pread,c2pwrite,errread_restore_als,errgid,未使用未使用的gids,未使用的uid,未使用的umask,未使用的启动新会话)1418#启动进程1419尝试:-> 1420 hp,ht,pid,tid = _winapi.CreateProcess(executable,args,1421#无特殊安全性1422无,无,

PermissionError: [WinError 5] Access is denied ''' PermissionError: [WinError 5] 访问被拒绝'''

The path included was incorrect... It's working now:) Hope this might help others with the same error.包含的路径不正确......它现在可以工作了:) 希望这可以帮助其他有同样错误的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM