Pytesseract 报错:'Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\pytesseract\pytesseract.py", line 255, in run_tesseract proc = subprocess.Popen(cmd_args, **subprocess_args()) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 966, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1435, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ...'' 解决方法
这个报错可能是由于 pytesseract 无法找到 Tesseract 可执行文件导致的。要解决此问题,可以尝试以下方法:
-
确保已经安装了 Tesseract OCR 引擎,并且已经将其路径添加到系统环境变量中。
-
如果已经安装了 Tesseract OCR 引擎,但是仍然无法正常工作,请尝试指定 Tesseract 可执行文件的路径。可以通过设置
pytesseract.pytesseract.tesseract_cmd属性来实现:
pytesseract.pytesseract.tesseract_cmd = 'path/to/tesseract'
-
如果在 Windows 上运行代码,请确保在代码中使用的 Python 解释器和 Tesseract OCR 引擎都是 32 位或 64 位版本。如果不匹配,可能会导致问题。
-
如果您使用的是 Anaconda 或其他虚拟环境,请确保安装了 Tesseract OCR 引擎,并且已经将其路径添加到虚拟环境的环境变量中。
-
如果仍然无法解决问题,请尝试升级或降级 pytesseract 和 Tesseract OCR 引擎的版本,或者使用其他 OCR 库。
原文地址: https://www.cveoy.top/t/topic/mtbb 著作权归作者所有。请勿转载和采集!