IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> Python知识库 -> pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it‘s not in your PATH. -> 正文阅读

[Python知识库]pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it‘s not in your PATH.

一.问题背景

python使用tesseract,已经使用命令行安装了pytesseract
在这里插入图片描述
运行读取验证码测试代码:

#coding=utf-8
from PIL import Image
import pytesseract

#非规则性
image = Image.open("D:\D1\TestDevelopment\data\SeleniumData\shot2.png")
text = pytesseract.image_to_string(image)
print("非规则性图片读取----->",text)

#非规则性
image1 = Image.open("D:\D1\TestDevelopment\data\SeleniumData\shot3.webp")
text1 = pytesseract.image_to_string(image1)
print("规则性图片读取----->",text1)

完整报错信息如下:

Traceback (most recent call last):
  File "D:\D1\IDEs\Python3.8.5\lib\site-packages\pytesseract\pytesseract.py", line 252, in run_tesseract
    proc = subprocess.Popen(cmd_args, **subprocess_args())
  File "D:\D1\IDEs\Python3.8.5\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "D:\D1\IDEs\Python3.8.5\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".\chapter2\start_browser2-14.py", line 7, in <module>
  File "D:\D1\IDEs\Python3.8.5\lib\site-packages\pytesseract\pytesseract.py", line 413, in image_to_string
    return {
  File "D:\D1\IDEs\Python3.8.5\lib\site-packages\pytesseract\pytesseract.py", line 416, in <lambda>
    Output.STRING: lambda: run_and_get_output(*args),
  File "D:\D1\IDEs\Python3.8.5\lib\site-packages\pytesseract\pytesseract.py", line 284, in run_and_get_output
    run_tesseract(**kwargs)
  File "D:\D1\IDEs\Python3.8.5\lib\site-packages\pytesseract\pytesseract.py", line 256, 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的使用还需要安装Pillow,tesseract-ocr,由于之前已经安装过pillow,故只需要安装tesseract-ocr

具体步骤如下:
1.安装tesseract
https://github.com/tesseract-ocr/tesseract

在这里插入图片描述

2.修改1目录下pytesseract.py文件,指定tesseract.exe安装路径

tesseract_cmd = r'D:\\D1\\python\\tesseract\\Tesseract-OCR\\tesseract.exe'

3.增加系统环境变量
在这里插入图片描述

编辑path系统环境变量

在这里插入图片描述

4.编辑环境变量后重新打开cmd窗口,输入
在这里插入图片描述
5.最后重新运行代码,能成功运行输出
在这里插入图片描述
参考文章:
https://blog.csdn.net/JavaBigData/article/details/108030678

  Python知识库 最新文章
Python中String模块
【Python】 14-CVS文件操作
python的panda库读写文件
使用Nordic的nrf52840实现蓝牙DFU过程
【Python学习记录】numpy数组用法整理
Python学习笔记
python字符串和列表
python如何从txt文件中解析出有效的数据
Python编程从入门到实践自学/3.1-3.2
python变量
上一篇文章      下一篇文章      查看所有文章
加:2021-07-17 11:52:21  更:2021-07-17 11:54:36 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/5 0:09:56-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码