Python:AttributeError:模块“camelot”没有属性“read_pdf”

问题描述

面临以下问题:有人可以帮忙吗?请..

尝试从 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 有关。服务器(无头)环境没有安装 GUI 包,所以如果你在没有 GUI 的服务器上使用 Camelot,你应该先安装 opencv-python-headless:

pip install opencv-python-headless

然后与camelot.io一起导入,而不是camelot:

import camelot.io as camelot
import cv2

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...