当Python遇到PIL|pytesser图像处理出错


import pytesser
From PIL import Image
im = Image.open('1.png')
im.show()#查看图片
print pytesser.image_to_string(im)#识别图像的字符串




这样会报错如下:

C:\Python27\python.exe C:/Users/ED/PycharmProjects/untitled/1t.py
Traceback (most recent call last):
  File "C:/Users/ED/PycharmProjects/untitled/1t.py", line 14, in 
    print pytesser.image_to_string(im)
  File "C:\Python27\lib\site-packages\pytesser\pytesser.py", line 31, in 

image_to_string
    call_tesseract(scratch_image_name, scratch_text_name_root)
  File "C:\Python27\lib\site-packages\pytesser\pytesser.py", line 21, in call_tesseract
    proc = subprocess.Popen(args)
  File "C:\Python27\lib\subprocess.py", line 709, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 957, in _execute_child
    startupinfo)
WindowsError: [Error 2] 

解决方法:
import  os
os.chdir('c:/Python27/Lib/site-packages/pytesser')#修改工作路径即可
简单的数字和英文的图像识别就完成了


你可能感兴趣的:(Python)