win10安装tesserocr配置 Python使用tesserocr识别字母数字验证码
鏈接:https://pan.baidu.com/s/1l2yiba7ZTPUTf41ZnJ4PYw
提取碼:t3bq
win10安裝tesserocr
首先需要下載tesseract,它為tesserocr提供底層支持。具體下載官方路徑:https://github.com/UB-Mannheim/tesseract/wiki,選擇對應的系統版本,可以選擇一個相對不帶dev的穩定版本下載,如:tesseract-ocr-setup-3.05.02-20180621.exe。然后一路安裝,唯一記得勾選Additional language data(download),勾選可能會用到的語言tessdata,如簡體、繁體中文,數學模塊等,不需要全選,下載tessdata的時間會比較長。
下載時間會比較長,耐心等待即可,有條件可以翻墻下載速度會快很多
安裝python對應的tesserocr庫
使用原始的whl文件方式安裝。tesserocr 的whl官方文件下載路徑:https://github.com/simonflueckiger/tesserocr-windows_build/releases,下載本地環境對應的whl文件,如我的是window64位系統,python版本是3.5。下載完后,使用cd跳轉到whl文件所在目錄,然后 執行 ”pip install tesserocr-2.2.2-cp35-cp35m-win_amd64.whl“,即可輕松完成安裝。
tesserocr 報錯 UnicodeDecodeError 系統問題 用下面的模塊替代
pytesseract :pip install pytesseract
首次運行總是不順利,相信我遇到的坑大多數人都會遇到,大抵錯誤類似:
Traceback (most recent call last):File "G:\pythonSources\my12306/obtain_message\test.py", line 4, in <module>print(tesserocr.image_to_text(image))File "tesserocr.pyx", line 2400, in tesserocr._tesserocr.image_to_text RuntimeError: Failed to init API, possibly an invalid tessdata path: “本地某個路徑”有個比較簡單粗暴的解決方法是把安裝好的Tesseract-OCR下的tessdata文件夾整個拷貝到提示的那個路徑中,親測有效。
測試代碼
import tesserocr from PIL import Image image=Image.open('image.jpg') print(tesserocr.image_to_text(image))本文僅供學習交流使用,如侵立刪!
總結
以上是生活随笔為你收集整理的win10安装tesserocr配置 Python使用tesserocr识别字母数字验证码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mitmproxy配置代理后 APP连接
- 下一篇: contos 安装vim自动补全插件 Y