解决python中使用tesserocr会报tessdata路径错误问题

测试代码:
im=Image.open(‘image.png’)
print(tesserocr.image_to_text(im))
错误:
C:\Users\ht\AppData\Local\Programs\Python\Python36\python.exe D:/Python/src/chorme.py
Traceback (most recent call last):
File “D:/Python/src/chorme.py”, line 17, in
print(tesserocr.image_to_text(im))
File “tesserocr.pyx”, line 2401, in tesserocr._tesserocr.image_to_text
RuntimeError: Failed to init API, possibly an invalid tessdata path: D:\Users\ht\AppData\Local\Programs\Python\
解决方案
最初根据网上方法将tessdata放入python安装目录C:\Users\ht\AppData\Local\Programs\Python\Python36问题未解决,后在D盘新建目录D:\Users\ht\AppData\Local\Programs\Python\并将tessdata移入仍未解决,经对比发现报错目录比安装目录少了最后一层Python36,于是将报错的D盘目录建为D:\Users\ht\AppData\Local\Programs\Python\Python36与python安装目录同深度,问题得到解决

你可能感兴趣的:(学习笔记)