踩坑|Python自动化办公实战课
感觉极客时间里专栏课的形式更好,但质量有时像是图文不匹配的公众号文章。。
作者给出的代码与练习文档的链接
01 xlsx合并拆分
因xlrd版本过高,无法读取xlxs文件,参考xlrd.biffh.XLRDError: Excel xlsx file; not supported,重新安装即可
pip3 install xlrd==1.2.0
02 docx合并拆分
代码链接与专栏匹配得挺乱的(可能是缺少能直接用的代码段),我想先去看会《Word排版艺术》
03 文字识别
在离线文字识别部分使用tesseract时出现错误,报错信息
pytesseract.pytesseract.TesseractError: (1, 'Error opening data file C:\\Program Files\\Tesseract-OCR/tessdata/chi_sim.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language \'chi_sim\' Error opening data file /home/debian/src/github/tesseract-ocr/tesseract/bin/ndebug/x86_64-w64-mingw32-5.0.0-alpha.20201127/usr/x86_64-w64-mingw32/share/tessdata/eng.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language \'eng\' Tesseract couldn\'t load any languages! Could not initialize tesseract.')
-
装pytesseract库
pip3 install tesseract
-
安装二进制文件
下载https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w64-setup-v5.0.0-alpha.20201127.exe
默认安装即可
-
更改pytesseract.py
tesseract_cmd = 'tesseract' ##更换为 tesseract_cmd = '上述文件的安装地址'#我的是'C:\\Program Files\\Tesseract-OCR\\tesseract.exe'
-
安装中文包
https://raw.githubusercontent.com/tesseract-ocr/tessdata/4.00/chi_sim.traineddata
放入Tesseract-OCR\tessdata文件夹中,可查找eng.traineddata路径
更新中···