Facing below issue: can anyone help? please.. Getting the below while trying to extract table data from PDF's..
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'
asked Jan 10, 2021 at 14:44
P Krishnama Naidu P Krishnama Naidu
45 1 1 silver badge 7 7 bronze badges
This error most likely occured because you installed the wrong package.
When you installed the camelot module, you should have used this:
pip install camelot-py[cv]
If not, uninstall the package you installed and use the above command.
answered Jan 10, 2021 at 14:54 DapperDuck DapperDuck 2,838 1 1 gold badge 10 10 silver badges 25 25 bronze badges Doubtful this is the problem. Did you read what the AttributeError said? Commented Jan 10, 2021 at 14:58@martineau Ah, you're right. I went through some more github issues and I found the actual problem. I'll update my answer!
Commented Jan 10, 2021 at 15:05I encounted the same problem and tried many things, including install/uninstall various camelot packages, cloning git, etc. It didn't work for me. I found that the issue was related to CV2. Server (headless) environments do not have GUI packages installed so if you are using Camelot on the server with no GUI you should instal opencv-python-headless first:
pip install opencv-python-headless
and then import in along with camelot.io insteatd of camelot:
import camelot.io as camelot import cv2