面对以下问题:有人能帮忙吗?请
在尝试从PDF中提取表格数据时获取以下信息。。
import camelot
# PDF file to extract tables from
file = input_folder+file_name
tables = camelot.read_pdf(file)
# number of tables extracted
print("Total tables extracted:", tables.n)
# print the first table as Pandas DataFrame
print(tables[0].df)
Error: AttributeError: module 'camelot' has no attribute 'read_pdf'
此错误很可能是因为安装了错误的软件包。
当你安装camelot模块时,你应该使用这个:
pip install camelot-py[cv]
如果没有,请卸载您安装的软件包,然后使用上面的命令。
我遇到了同样的问题,并尝试了很多事情,包括安装/卸载各种camelot软件包、克隆git等。这对我来说不起作用。我发现这个问题与CV2有关。服务器(headless(环境没有安装GUI包,因此如果您在没有GUI的服务器上使用Camelot,则应首先安装opencv-python headless:
pip install opencv-python-headless
然后与camelot.io一起导入camelot:
import camelot.io as camelot
import cv2