pandas tabula-py 导入错误:无法导入名称“read_pdf”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47939921/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 04:57:01  来源:igfitidea点击:

tabula-py ImportError: cannot import name 'read_pdf'

pythonexcelpandaspdftabula

提问by DanielHe

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

我正在尝试使用 tabula-py 将表格从 pdf 传输到 excel。

When im trying to

当我试图

from tabula import read_pdf

it says

它说

ImportError: cannot import name 'read_pdf'

导入错误:无法导入名称“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

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

Tabula-py - ImportError: No module named tabula

Tabula-py - 导入错误:没有名为 tabula 的模块

But its still not working for me.

但它仍然不适合我。

Any ideas?

有任何想法吗?

回答by Jay Haran

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.

read_pdf 包含在“包装器”中。因此,您导入包装器并从包装器调用 read_pdf。

回答by ujjal das

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

也许这是因为您安装的 tabula 版本。

If you installed tabula by running:

如果您通过运行安装了 tabula:

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:

你得到一个旧版本的 tabula (1.0.5),它有模块 .read_pdf() 的问题。要解决该问题并获得更新版本的 tabula,请首先:

uninstall tabula with the command:

使用以下命令卸载 tabula:

pip uninstall tabula

And install the newer version of tabula with the command:

并使用以下命令安装较新版本的 tabula:

pip install tabula-py

I think this will solve your problem.

我认为这将解决您的问题。

回答by Salih Osman

I solved as follows:

我解决如下:

  1. upgrade pip to pi3: pip install --upgrade pip --user
  1. 将 pip 升级到 pi3: pip install --upgrade pip --user

pip3 uninstall tabula-py

pip3 卸载 tabula-py

pip3 install tabula-py

pip3 安装 tabula-py

That solved the problem perfectly! Good luck!

这样就完美解决了问题!祝你好运!

回答by JON

It worked for me when I have installed it with pip install tabula-py

当我安装它时它对我有用 pip install tabula-py

回答by Abdulrahman Bres

There is a chance that you might be testing tabula-py in a module you named tabula.py

您有可能在名为 tabula.py 的模块中测试 tabula-py

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

由于Python 中模块导入顺序,这将引发完全相同的错误