tabula-py ImportError: cannot import name 'read_pdf'

21,839

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:

  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!

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.

Share:
21,839
DanielHe
Author by

DanielHe

Updated on July 10, 2022

Comments

  • DanielHe
    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
    HMD about 6 years
    Please consider adding some explanation to your answer.
  • geekidharsh
    geekidharsh over 5 years
    I believe the issue arises becuase of tabula updating the method. Now the method read_pdf sits inside of wrapper.
  • yts61
    yts61 about 4 years
    nope, 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
    Strayhorn about 4 years
    It doesn't work. ImportError: cannot import name 'wrapper' from 'tabula' (/tmp/yes/lib/python3.7/site-packages/tabula/__init__.py)
  • mah65
    mah65 over 3 years
    It 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
    Mauricio about 2 years
    This did not immediately solve my problem because, I think, I had both tabula and tabula-py install. I had to uninstall both then reinstall tabula-py by itself to get it to work.