Python:AttributeError:module'camelot'没有属性'read\u pdf'

2024-06-28 20:34:49 发布

您现在位置:Python中文网/ 问答频道 /正文

面对以下问题:有人能帮忙吗?请

在尝试从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'

Tags: to数据fromimport信息readtablespdf
2条回答

我遇到了同样的问题,并尝试了很多事情,包括安装/卸载各种camelot软件包,克隆git等等。它对我不起作用。我发现这个问题与CV2有关。服务器(headless)环境没有安装GUI软件包,因此如果在没有GUI的服务器上使用Camelot,则应首先安装opencv python headless:

pip install opencv-python-headless

然后与camelot.io指令一起导入:

import camelot.io as camelot
import cv2

发生此错误的原因很可能是安装了错误的软件包

当您安装camelot模块时,您应该使用:

pip install camelot-py[cv]

如果没有,请卸载您安装的软件包并使用上述命令

相关问题 更多 >