tabula-py ImportError: cannot import name 'read_pdf'
Solution 1
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.
Solution 2
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.
Solution 3
I solved as follows:
- upgrade pip to pi3: pip install --upgrade pip --user
pip3 uninstall tabula-py
pip3 install tabula-py
That solved the problem perfectly! Good luck!
Solution 4
There is a chance that you might be testing tabula-py in a module you named tabula.py
This would throw the same exact error because of module import order in Python
Solution 5
Yes! I had this same problem. The file I was using to write the code was named 'tabula.py'. I wrote the code in a new file, with a new name, and had to delete the file named 'tabula.py'.
Once I did that the error went away.
DanielHe
Updated on July 10, 2022Comments
-
DanielHe almost 2 years
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?
-
HMD about 6 yearsPlease consider adding some explanation to your answer.
-
geekidharsh over 5 yearsI believe the issue arises becuase of tabula updating the method. Now the method read_pdf sits inside of wrapper.
-
yts61 about 4 yearsnope, it doesn't solve the problem, an error comes up : cannot import name 'wrapper' from 'tabula' (/usr/local/lib/python3.7/site-packages/tabula/__init_.py)_
-
Strayhorn about 4 yearsIt doesn't work. ImportError: cannot import name 'wrapper' from 'tabula' (/tmp/yes/lib/python3.7/site-packages/tabula/__init__.py)
-
mah65 over 3 yearsIt also solved my problem. However, the important thing was that I had to close CMD, and open again, and run a fresh jupyter notebook (simply restarting jupyter notebook did not work).
-
Mauricio about 2 yearsThis did not immediately solve my problem because, I think, I had both
tabula
andtabula-py
install. I had to uninstall both then reinstalltabula-py
by itself to get it to work.