mac安装pytesseract

pytesseract是google做的ocr库,可以识别图片中的文字,一般用在爬虫登录时验证码的识别,在安装pytesseract环境过程中会遇到各种坑的事情,如果你也遇到一样的问题,可以按照如下流程去做,避免踩坑!

安装方法

pip install pytesseract

此外还需安装Tesseract,切记使用brew

brew install tesseract

查看安装位置

brew list tesseract
/usr/local/Cellar/tesseract/4.1.1/bin/tesseract
/usr/local/Cellar/tesseract/4.1.1/include/tesseract/ (19 files)
/usr/local/Cellar/tesseract/4.1.1/lib/libtesseract.4.dylib
/usr/local/Cellar/tesseract/4.1.1/lib/pkgconfig/tesseract.pc
/usr/local/Cellar/tesseract/4.1.1/lib/ (2 other files)
/usr/local/Cellar/tesseract/4.1.1/share/tessdata/ (35 files)

配置环境变量

export TESSDATA_PREFIX=/usr/local/Cellar/tesseract/4.1.1/share/tessdata
export PATH=$PATH:$TESSDATA_PREFIX

如何出现如下报错

TesseractNotFoundError: tesseract is not installed or it’s not in your PATH

修改pytesseract.py的cmd

tesseract_cmd = '/usr/local/Cellar/tesseract/4.1.1/bin/tesseract'

说明:pytesseract.py的位置可以在报错位置找到。

posted @   帅气的Lucky  阅读(420)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~

喜欢请打赏

扫描二维码打赏

支付宝打赏

点击右上角即可分享
微信分享提示