使用Python机器识别库pytesseract遇到的问题

使用Python机器识别库pytesseract遇到的问题

# _*_ coding:utf-8 _*_

#机器识别使用tesseract

#导入机器识别库
import pytesseract
#导入PIL库
from PIL import Image

image = Image.open("page/test.png")
info = pytesseract.image_to_string(image)
print info

运行...然后报错

G:\Python27\python.exe G:/Py_Project/MyPythonProject2/mypython27.py
Traceback (most recent call last):
  File "G:/Py_Project/MyPythonProject2/mypython27.py", line 11, in <module>
    info = pytesseract.image_to_string(image)
  File "G:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string
    config=config)
  File "G:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract
    proc = subprocess.Popen(command, stderr=subprocess.PIPE)
  File "G:\Python27\lib\subprocess.py", line 390, in __init__
    errread, errwrite)
  File "G:\Python27\lib\subprocess.py", line 640, in _execute_child
    startupinfo)
WindowsError: [Error 2] 

Process finished with exit code 1



解决方法:

找到pytesseract库里的pytesseract.py文件

找到:tesseract_cmd = 'tesseract'

改成:tesseract_cmd = r'C:\Program Files (x86)\Tesseract-OCR\tesseract.exe'

tesseract_cmd = r'Tesseract安装路径'


改完后:

G:\Python27\python.exe G:/Py_Project/MyPythonProject2/mypython27.py
162408

Process finished with exit code 0

可以识别





  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值