【发布时间】:2019-02-28 09:17:15
【问题描述】:
我正在使用 Python 3.5 和 Anaconda 发行版。 tabula-py 版本 1.1.1 已安装。当我运行以下简单程序时:
import tabula
df = tabula.read_pdf("sample.pdf", pages=1, encoding="ISO-8859-1")
df.columns = df.iloc[0]
df.drop(0, inplace=True)
我收到以下错误消息:
AttributeError: module 'tabula' has no attribute 'read_pdf'
但是:如果我打开 Spyder 并在运行代码之前先在 IPython 控制台中键入“import tabula”,它运行得很好。如果我重新启动内核,我会得到同样的错误,直到我关闭并重新打开 Spyder。
有什么想法吗?提前致谢。
【问题讨论】:
-
是的。 Spyder 有一个共享的命名空间。导入的模块被缓存。你不应该依赖这种行为;您应该在脚本顶部显式导入模块
-
你叫你脚本
tabula.py吗?