Python TesseractNotFound-Windows

Python TesseractNotFound-Windows,python,ocr,tesseract,Python,Ocr,Tesseract,我正在尝试在Windows上使用tesseract,但无法使其正常工作 我下载了 tesseract-ocr-w64-setup-v5.0.0-alpha.20190708.exe(64位)resp. 从https://github.com/UB-Mannheim/tesseract/wiki 这就是我使用的代码: from PIL import Image import pytesseract im = Image.open("C:\\test.png") pytesseract.pytess

我正在尝试在Windows上使用tesseract,但无法使其正常工作

我下载了
tesseract-ocr-w64-setup-v5.0.0-alpha.20190708.exe(64位)resp.
https://github.com/UB-Mannheim/tesseract/wiki

这就是我使用的代码:

from PIL import Image
import pytesseract
im = Image.open("C:\\test.png")
pytesseract.pytesseract.tesseract_cmd = "C:\\Users\\User\\AppData\\Local\\Tesseract-OCR"
text = pytesseract.image_to_string(im, lang="eng")
print(text)
但它会抛出

pytesseract.pytesseract.TesseractNotFoundError:C:\Users\User\AppData\Local\Tesseract OCR未安装或不在您的路径中

同时:

PS C:\Users\User\AppData\Local\Tesseract-OCR> ls


Directory: C:\Users\User\AppData\Local\Tesseract-OCR


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       28.07.2019     17:23                doc
d-----       28.07.2019     17:23                tessdata
-a----       08.07.2019     23:07          17824 ambiguous_words.1.html
-a----       08.07.2019     23:07        1052899 ambiguous_words.exe
-a----       08.07.2019     23:07          19530 classifier_tester.1.html
-a----       08.07.2019     23:07        1869560 classifier_tester.exe
-a----       08.07.2019     23:07          18161 cntraining.1.html
-a----       08.07.2019     23:07        1697975 cntraining.exe
-a----       08.07.2019     23:07          21063 combine_lang_model.1.html
-a----       08.07.2019     23:07        4192836 combine_lang_model.exe
-a----       08.07.2019     23:07          27013 combine_tessdata.1.html
-a----       08.07.2019     23:07        1214080 combine_tessdata.exe
-a----       08.07.2019     23:07          18341 dawg2wordlist.1.html
-a----       08.07.2019     23:07         803202 dawg2wordlist.exe
-a----       02.12.2013     02:33          33792 iconv.dll
-a----       25.04.2019     22:03       27547648 icudt64.dll
-a----       25.04.2019     22:04        2583059 icuin64.dll
-a----       25.04.2019     22:04        1631763 icuuc64.dll
-a----       27.10.2017     08:25         693248 libarchive-13.dll
-a----       03.12.2013     05:15          71168 libbz2-1.dll
-a----       20.02.2018     05:33         891392 libcairo-2.dll
-a----       19.07.2017     03:22         159232 libexpat-1.dll
-a----       23.11.2015     08:01          31744 libffi-6.dll
-a----       20.02.2018     05:22         276480 libfontconfig-1.dll
-a----       20.03.2018     04:06         642048 libfreetype-6.dll
-a----       20.06.2019     18:07        1208273 libgcc_s_seh-1.dll
-a----       27.02.2018     06:20          39955 libgif-7.dll
-a----       20.02.2018     04:19        1105920 libglib-2.0-0.dll
-a----       20.02.2018     04:19         304128 libgobject-2.0-0.dll
-a----       20.06.2019     18:07        1730128 libgomp-1.dll
-a----       11.04.2018     09:35         702976 libharfbuzz-0.dll
-a----       23.10.2016     22:54         132608 libintl-8.dll
-a----       09.04.2014     06:47          57344 libjbig-2.dll
-a----       18.12.2017     03:49         414720 libjpeg-8.dll
-a----       13.03.2019     09:20       12166848 liblept-5.dll
-a----       04.09.2017     01:50         124416 liblz4-1.dll
-a----       10.05.2017     04:33         148480 liblzma-5.dll
-a----       16.03.2018     01:40         216576 libnettle-6.dll
-a----       20.03.2018     04:27         384000 libopenjp2.dll
-a----       20.02.2018     06:27         284672 libpango-1.0-0.dll
-a----       20.02.2018     06:27          58880 libpangocairo-1.0-0.dll
-a----       20.02.2018     06:27          79872 libpangoft2-1.0-0.dll
-a----       20.02.2018     06:27          67072 libpangowin32-1.0-0.dll
-a----       24.04.2017     04:36         296960 libpcre-1.dll
-a----       08.08.2016     03:59         662016 libpixman-1-0.dll
-a----       18.12.2017     03:38         219648 libpng16-16.dll
-a----       20.06.2019     18:07       19441775 libstdc++-6.dll
-a----       08.07.2019     22:53       84748359 libtesseract-5.dll
-a----       18.12.2017     04:09         451072 libtiff-5.dll
-a----       18.12.2017     04:19         426496 libwebp-7.dll
-a----       11.11.2018     20:47         592104 libwinpthread-1.dll
-a----       26.08.2016     21:10        1255424 libxml2-2.dll
-a----       08.07.2019     23:07          19471 lstmeval.1.html
-a----       08.07.2019     23:07        4272707 lstmeval.exe
-a----       08.07.2019     23:07          22574 lstmtraining.1.html
-a----       08.07.2019     23:07        4487308 lstmtraining.exe
-a----       08.07.2019     23:07          18951 merge_unicharsets.1.html
-a----       08.07.2019     23:07         718940 merge_unicharsets.exe
-a----       08.07.2019     23:07          19432 mftraining.1.html
-a----       08.07.2019     23:07        2230154 mftraining.exe
-a----       08.07.2019     23:07          19114 set_unicharset_properties.1.html
-a----       08.07.2019     23:07        4210926 set_unicharset_properties.exe
-a----       08.07.2019     23:07          19453 shapeclustering.1.html
-a----       08.07.2019     23:07        1866701 shapeclustering.exe
-a----       28.07.2019     17:26         129798 tesseract-uninstall.exe
-a----       08.07.2019     23:07          41596 tesseract.1.html
-a----       08.07.2019     22:53         966583 tesseract.exe
-a----       08.07.2019     23:07          25670 text2image.1.html
-a----       08.07.2019     23:07        7208434 text2image.exe
-a----       08.07.2019     23:07          21257 unicharambigs.5.html
-a----       08.07.2019     23:07          23834 unicharset.5.html
-a----       08.07.2019     23:07          18817 unicharset_extractor.1.html
-a----       08.07.2019     23:07        4195211 unicharset_extractor.exe
-a----       08.07.2019     22:01          19154 winpath.exe
-a----       08.07.2019     23:07          19497 wordlist2dawg.1.html
-a----       08.07.2019     23:07        1122624 wordlist2dawg.exe
-a----       03.03.2017     22:48          91136 zlib1.dll
所以,看起来它确实存在,那么有什么问题呢?

解决方案:

使用EXE的路径

pytesseract.pytesseract.tesseract_cmd='C:\Users\User\AppData\Local\tesseract OCR\tesseract.exe'