• python获取图片验证码


    一、安装linux下图片处理工具:

    # which tesseract
    /usr/bin/tesseract

    二、安装python连接模块:

    pip install pytesseract

    pip install Pillow

    三、进入python运行环境:

    1报错:

    File "/usr/lib/python2.7/site-packages/pytesseract/pytesseract.py", line 194, in image_to_string
    return run_and_get_output(image, 'txt', lang, config, nice)
    File "/usr/lib/python2.7/site-packages/pytesseract/pytesseract.py", line 141, in run_and_get_output
    run_tesseract(**kwargs)
    File "/usr/lib/python2.7/site-packages/pytesseract/pytesseract.py", line 112, in run_tesseract
    proc = subprocess.Popen(command, stderr=subprocess.PIPE)
    File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
    File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
    OSError: [Errno 2] No such file or directory

    修改源码:

    vim /usr/lib/python2.7/site-packages/pytesseract/pytesseract.py

    修改为绝对路径:(

    tesseract_cmd = '/usr/bin/tesseract'

    >>> import pytesseract
    >>> from PIL import Image
    >>> image = Image.open('/tmp/cap.jpg')
    >>> vcode = pytesseract.image_to_string(image)

    >>> print(vcode)
    blZgb

  • 相关阅读:
    DB-MySQL:MySQL 函数
    DB-MySQL:目录
    文学-人物:王阳明
    院校:伦敦大学学院
    文学-人物:曹操
    文学-人物:诸葛亮
    x2go
    PHP+jQuery 注册模块开发
    java中Runtime类详细介绍
    java中Runtime类详细介绍
  • 原文地址:https://www.cnblogs.com/songge1209/p/8511338.html
Copyright © 2020-2023  润新知