camelot 安装和使用踩坑

#报错1 AttributeError: module 'camelot' has no attribute 'read_pdf'

  • 卸载camelot,重新安装
pip uninstall camelot
pip install "camelot-py[base]"

#报错2 Getting PyPDF2 error while using the camelot library

pip uninstall PyPDF2
pip uninstall PyPDF2===1.26.0

# ghostscript安装

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
brew install ghostscript

# 使用camelot

import camelot.io as camelot
import glob
PDFFile = glob.glob(r'./PDF/*.pdf')
tables = camelot.read_pdf(PDFFile[1], pages='all')   
print(tables[0].df) 
tables[0].to_csv("test.csv ")

# 参考

Camelot: PDF Table Extraction for Humans
Install ghostscript on Mac OSX
AttributeError: module 'camelot' has no attribute 'read_pdf'

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。