FileNotFoundError:[WinError 2]尝试使用pytesseract时,系统找不到指定的文件

时间:2017-12-07 15:42:37

标签: python

< p>我正在尝试编写一个python脚本来从图像中提取文本,并且我不断收到此错误。脚本如下。 < a href =" https://i.stack.imgur.com/Qanga.jpg" rel =" nofollow noreferrer">错误< / a>< / p> 来自PIL导入图片的< pre>< code> 来自pytesseract import image_to_string print(image_to_string(Image.open(' samp.png'))) print(image_to_string(Image.open(' test-english.jpg'),lang =' eng')) < /代码>< /预>

1 个答案:

答案 0 :(得分:1)

尝试以下步骤,这对我有用。

1)从here下载tesseract-OCR并将其安装在<div ng-app="app" ng-controller="myCtrl as vm"> <ui-select multiple tagging ng-model="vm.selected" theme="bootstrap"> <ui-select-match placeholder="Pick one...">{{$item.value}}</ui-select-match> <ui-select-choices repeat="val in vm.values | filter: $select.search track by val.value"> <div ng-bind="val.value | highlight: $select.search"></div> </ui-select-choices> </ui-select> </div>

位置

2)编写以下代码

C:/Program Files

from PIL import Image from pytesseract import image_to_string

#pytesseract.pytesseract.tesseract_cmd = '<full_path_to_your_tesseract_executable>'

3)现在运行

pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files/Tesseract-OCR/tesseract.exe' 

希望有所帮助!