Reputation: 239
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?
Upvotes: 17
Views: 43405
Reputation: 1126
I fixed this error by changing the python interpreter path in pychram
Upvotes: 0
Reputation: 2913
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
Upvotes: 2
Reputation: 811
Easy Solution - 1- uninstall the old tabula
pip uninstall tabula
2- install the new tabula-py
pip install tabula-py
then use the module
from tabula import read_pdf
Upvotes: 0
Reputation: 1
try:
from tabula.io import read_pdf
df = read_pdf('file.pdf', pages='all')
Upvotes: -1
Reputation: 11
Step 1:- Upgrade PIP
python.exe -m pip install --upgrade pip --u
Step2 : make sure its upgraded in your virtual environment
(venv) D:\dMig\venv\Lib\site-packages>pip install --upgrade pip --user
Requirement already up-to-date: pip in d:\python38\lib\site-packages (20.2)
Step3: Uninstall earlier version
(venv) D:\dMig\venv\Lib\site-packages>pip3 uninstall tabula-py
Step4: Install again
pip3 install tabula-py
Step5: Verify by below code
from tabula import read_pdf
#declare the path of your file
file_path = "E:\Activity.pdf"
#Convert your file
df = read_pdf(file_path)
print(df)
Upvotes: 1
Reputation: 11
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.
Upvotes: 1
Reputation: 927
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.
Upvotes: 16
Reputation: 71
I solved as follows:
pip3 uninstall tabula-py
pip3 install tabula-py
That solved the problem perfectly! Good luck!
Upvotes: 5
Reputation: 123
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.
Upvotes: 6