使用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/文件夹下后,加载一切正常;