pytesseract 加载字符库文件报错Error opening data file /usr/share/tessdata/chi_sim.traineddata Please make sur

使用pytesseract加载一个chi_sim的中文字符库,

text = pytesseract.image_to_string(enhanced, lang='chi_sim')

弹出报错,*** pytesseract.pytesseract.TesseractError: (1, '[DS] Profile read from file (tesseract_opencl_profile_devices.dat). [DS] Device[1] 0:(null) score is 3.303500 [DS] Selected Device[1]: "(null)" (Native) Error opening data file /usr/share/tessdata/chi_sim.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language \'chi_sim\' Tesseract couldn\'t load any languages! Could not initialize tesseract.');

一开始没在意,到/usr/share/tessdata/文件夹下面看了一下确实没有chi_sim.traineddata,只有英文的,从https://github.com/tesseract-ocr/tessdata_best/blob/main/chi_sim.traineddata上wget了一个,放到了/usr/share/tessdata/目录下,结果还是报相同的错误;

后来看了一下,wget下来的文件比较小,只有200多k,就用网页在github上重新下载了一次,这次下载了有500多k,放到目录下后还是继续报错,后来想到估计是文件没有下载全,重新再github上选择了一次文件,但是这次没有直接下载,而是选择 "Raw" 选项后,再下载,此时下载下来的文件有12M左右,然后再放入到/usr/share/tessdata/文件夹下后,加载一切正常;

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值