解决:pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it‘s not in your PATH. See README file for more information.
问题:使用pytesseract库识别图片中文字时出现报错
代码:
import pytesseract
from PIL import Image,ImageEnhance
img=Image.open(r'F:\Test\venv\vfi_code.png') #修改图片的灰度,提高识别准确性
img=img.convert('RGB')
enhancer=ImageEnhance.Color(img)
enhancer=enhancer.enhance(0)
enhancer=ImageEnhance.Brightness(enhancer)
enhancer=enhancer.enhance(2)
enhancer=ImageEnhance.Contrast(enhancer)
enhancer=enhancer.enhance(8)
enhancer=ImageEnhance.Sharpness(enhancer)
img=enhancer.enhance(20) code=pytesseract.image_to_string(img,lang='chi_sim')
print(code)
原因:在安装pytesseract库后还需要安装Tesseract-OCR才能正常使用
解决办法:
1)先下载对应版本的Tesseract-OCR并安装,安装时记得把语言包都勾上。下载链接:Index of /tesseract
没有勾选语言包会有这个报错:
pytesseract.pytesseract.TesseractError: (1, 'Error opening data file C:\\Program Files\\Tesseract-OCR/tessdata/chi_sim.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language \'chi_sim\' Tesseract couldn\'t load any languages! Could not initialize tesseract.')
2)将安装路径C:\Program Files\Tesseract-OCR 添加到系统环境变量Path里;再增加一个TESSDATA_PREFIX变量名,变量值还是我的安装路径C:\Program Files\Tesseract-OCR\tessdata这是将语言字库文件夹添加到变量中;
3)打开终端,输入:tesseract -v,可以看到版本信息
5)再运行脚本就没有报错了
解决:pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it‘s not in your PATH. See README file for more information.的更多相关文章
- pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path && FileNotFoundError: [WinError 2] 系统找不到指定的文件。
C:\Users\k\Desktop\test>python test.py Traceback (most recent call last): File , in run_tesseract ...
- pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path
使用pytesseract识别验证码中遇到异常如下: pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installe ...
- 解决pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path问题
解决方案: 找到python的安装路径下的pytesseract: 例如我的是 C:\develop\Python\Lib\site-packages\pytesseract .用文本编辑器打开 ...
- pytesseract.pytesseract.TesseractError: (1, 'Error opening data file /usr/local/share/tessdata/chi_sim.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata"
pytesseract.pytesseract.TesseractError: (1, 'Error opening data file /usr/local/share/tessdata/chi_s ...
- 报错解决——pytesseract.pytesseract.TesseractError: (1,’Error opening data file /usr/local/share/tessdata/eng.traineddata’)
解决方法:(原文地址http://stackoverflow.com/questions/14800730/tesseract-running-error) $ wget https://tesser ...
- tesseract-ocr和tesseract.exe is not installed or it's not in your path问题解决
一.解决方案: 1.http://www.ddooo.com/softdown/94968.htm 打开下载的压缩包,找到"tesseract-ocr-setup-3.02.02.exe ...
- 解决: org.iq80.leveldb.DBException: IO error: C:\data\trie\000945.sst: Could not create random access file.
以太坊MPT树的持久化层是采用了leveldb数据库,然而在抽取MPT树代码运行过程中,进行get和write操作时却发生了错误: Caused by: org.fusesource.leveldbj ...
- 解决tomcat开始出现in production environments was not found on the java.library.path:xxx
如图所看到的,Eclipse中启动tomcat时出现not found on the java.library.path等信息.能够通过下载tomcat-native-1.1.32-win32-bin ...
- 如何解决"The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path"
今天我在eclipse上搭建新项目时,莫名其妙的出现这个错误,如下: The superclass "javax.servlet.http.HttpServlet" was not ...
- 解决spark运行中failed to locate the winutils binary in the hadoop binary path的问题
1.下载hadoop-common-2.2.0-bin并解压到某个目录 https://github.com/srccodes/hadoop-common-2.2.0-bin 2.设置hadoop.h ...
随机推荐
- Django中的app模型细节TypeError: __init__() missing 1 required positional argument: 'on_delete' 解决办法
TypeError: init() missing 1 required positional argument: 'on_delete' 解决办法 当执行应用app模型迁移时: python man ...
- ThinkPHP获取当前url
$httpType = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTT ...
- 批量获取title
1 import requests 2 from bs4 import BeautifulSoup 3 import pandas as pd 4 from openpyxl import Workb ...
- debian11 配置samba服务 linuxsys
一.安装软件包 sudo apt -y install samba samba-common 二.linux系统添加samba需要用的账户,创建需要共享的文件夹,并配置好权限.(注意共享文件夹最好不要 ...
- The 17th Zhejiang Provincial Collegiate Programming Contest B.Bin Packing Problem
题意 给定n个物品,和一个容量为C的桶 需要求出为了装下这些物品,分别使用首次适应算法(FF).最佳适应算法(BF)需要的桶的数量 \(n \leq 10^6\) 思路 BF:容易想到可以用set维护 ...
- java8 升级 17 兼容测试 emt4j
测试兼容性的,emt4j 在readme 里 download 节目,点击下载 https://github.com/adoptium/emt4j /root/emt4j-0.3/bin/analys ...
- CUDA Arch 代码
- MVP模式(转)
什么是MVP模式? 这个MVP可不是腾讯游戏<王者荣耀>中的MVP.我们今天要讨论的MVP其实同MVC一样,是一种编程模式和思想,也许更准确地讲是一种架构. MVP和MVC的区别 ...
- rsyslog由于RateLimit丢失日志的处理
问题 问题的发现:在我们的docker应用中,配置了rsyslog作为日志输出:当应用产生的日志在某段时间内量比较大时,就发现会丢日志. 原因 问题的原因:日志的输出路径,应用程序把日志输出到syst ...
- css布局、动画要点
background属性 属性解释background属性是css中应用比较多,且比较重要的一个属性,它是负责给盒子设置背景图片和背景颜色的,background是一个复合属性,它可以分解成如下几个设 ...