15

I am trying to extract tables from pdf using camelot and I get this attribute error. Could you please help?

import camelot
import pandas as pd
pdf = camelot.read_pdf("Gordian.pdf")

AttributeError Traceback (most recent call last) in ----> 1 pdf = camelot.read_pdf("Gordian.pdf")

AttributeError: module 'camelot' has no attribute 'read_pdf'

theduck
  • 2,589
  • 13
  • 17
  • 23
Yousra
  • 151
  • 1
  • 1
  • 3

7 Answers7

18

NOTE : If you are using virtual environment activate environment before do this things.

I have already faced this error.There is a no bug in your code.The problem is with camelot installation.

1 remove installed camelot version

2 install again using this command. There is a multiple ways to install camelot. Please try it one by one

  • pip install camelot-py
  • pip install camelot-py[cv]
  • pip install camelot-py[all]

3 run your code >> i have attached sample code here

import camelot

data = camelot.read_pdf("test_file.pdf", pages='all')
print(data)
waruna k
  • 842
  • 10
  • 20
6

Try this: import camelot.io as camelot That worked for me.

Chadee Fouad
  • 2,630
  • 2
  • 23
  • 29
4

please check if you have java installed on you machine, go to your terminal and run "java -version", if you do not have you won't be able to read pdf using Camelot or tabula,

once you have installed java, install tabula-py using the command pip install tabula-py.

from tabula.io import read_pdf
tables = read_pdf('file.pdf')  # substitute your file name
VirtualScooter
  • 1,792
  • 3
  • 18
  • 28
3

I abandoned trying to get camelot to work in Jupiter Notebooks to read tables & instead installed the following:

!{sys.executable} -m pip install tabula-py tabulate

from tabula import read_pdf
from tabulate import tabulate


pdf_path = (
    Path.home()
    / "my_pdf.pdf"
)
df = read_pdf(str(pdf_path), pages=1)
df[0]
Joe Gasewicz
  • 1,252
  • 15
  • 20
1

Here's the link with full installation steps: https://camelot-py.readthedocs.io/en/master/user/install.html#using-pip

After you install

pip install camelot-py[cv]

Write this:

import camelot.io as camelot
Desert Eagle
  • 191
  • 14
0

pip uninstall camelot pip uninstall camelot-py pip install camelot-py[cv]

install ghostscript app from internet

! apt install ghostscript python3-tk pip install ghostscript

JAGJ jdfoxito
  • 747
  • 5
  • 5
-1

When downloading the library please pay attention to where it is downloaded. Because the library you downloaded may have been saved in another Python version

Umit KOC
  • 224
  • 2
  • 6
  • Hello and welcome to SO! Please read the [tour](https://stackoverflow.com/tour), and [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer) For example you can elaborate how to pay this kind of attention, what would you expect ti find, annd how it should be fixed. – Tomer Shetah Jan 17 '21 at 13:01