Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tabula-py ImportError: cannot import name 'read_pdf'

Im trying to use tabula-py to transfer a table from pdf to excel.

When im trying to

from tabula import read_pdf

it says

ImportError: cannot import name 'read_pdf'

All solutions i found say that i have to

pip uninstall tabula
pip3 install tabula-py

https://github.com/chezou/tabula-py/issues/47

Tabula-py - ImportError: No module named tabula

But its still not working for me.

Any ideas?

like image 972
DanielHe Avatar asked Dec 22 '17 10:12

DanielHe


4 Answers

Maybe this is because of the version of tabula you installed.

If you installed tabula by running:

pip install tabula

You get an old version of tabula (1.0.5) that has the problem with the module .read_pdf(). To fix the problem and get a newer version of tabula, first:

uninstall tabula with the command:

pip uninstall tabula

And install the newer version of tabula with the command:

pip install tabula-py

I think this will solve your problem.

like image 128
2 revs, 2 users 82% Avatar answered Nov 12 '22 13:11

2 revs, 2 users 82%


from tabula import wrapper
df = wrapper.read_pdf('my_pdf')

read_pdf is contained within 'wrapper'. Hence you import wrapper and call read_pdf from wrapper.

like image 25
Jay Haran Avatar answered Nov 12 '22 14:11

Jay Haran


I solved as follows:

  1. upgrade pip to pi3: pip install --upgrade pip --user

pip3 uninstall tabula-py

pip3 install tabula-py

That solved the problem perfectly! Good luck!

like image 3
Salih Osman Avatar answered Nov 12 '22 14:11

Salih Osman


There is a chance that you're testing tabula-py within a module you named tabula.py

This would throw the same exact error because of module import order in Python

like image 2
Abdulrahman Bres Avatar answered Nov 12 '22 14:11

Abdulrahman Bres