python获取文件列表失败_python – Pytesseract没有这样的文件或目录错误

首先,我做了

pytesseract-no such file or directory error所提到的一切

仍然无法正常工作.现在我正在使用Pycharm IDE以下代码:

from PIL import Image

import pytesseract

import subprocess

im = Image.open('test.png')

im.show()

subprocess.call(['tesseract','test.png','out'])

print pytesseract.image_to_string(Image.open('test.png'))

> im.show()成功打开图像.

>带有tesseract test.png的s​​ubprocess.call()也会提取文本

从图像..

>但pytesseract.image_to_string()失败.

我不明白.为什么我能在shell中使用tesseract而不能在python中使用tesseract.在python中我可以打开相同的图像但是当与tesseract一起使用时无法找到图像.

您可以在下面看到错误输出.

File "/home/hamza-c/Schreibtisch/Android/JioShare/orc.py", line 7, in

print pytesseract.image_to_string(Image.open('/home/hamza-c/Schreibtisch/Android/JioShare/test.png'))

File "/usr/local/lib/python2.7/dist-packages/pytesseract/pytesseract.py", line 162, in image_to_string

config=config)

File "/usr/local/lib/python2.7/dist-packages/pytesseract/pytesseract.py", line 95, in run_tesseract

stderr=subprocess.PIPE)

File "/usr/lib/python2.7/subprocess.py", line 711, in __init__

errread, errwrite)

File "/usr/lib/python2.7/subprocess.py", line 1340, in _execute_child

raise child_exception

OSError: [Errno 2] No such file or directory

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值