验证码识别

环境安装:

工欲善其事,必先利其器。

  • python3
    brew install imagemagick
    brew install tesseract
    pip3 install tesserocr pillow

  • python2
    sudo pip install image
    sudo pip install tesserocr

测试代码:

#!/usr/bin/env python
# coding=utf-8
import tesserocr

print(tesserocr.file_to_text('image.png'))

运行故障:

导入tesserocr时命令行报错如上,无法导入。

解决方案:
运行程序前命令行运行:export LC_ALL=C
或配置进~/.bash_profile
执行相应的source命令即可

测试结果


你可能感兴趣的:(验证码识别)