【问题标题】:Tabula - AttributeError: module 'tabula' has no attribute 'read_pdf'Tabula - AttributeError: 模块 \'tabula\' 没有属性 \'read_pdf\'
【发布时间】:2023-02-16 17:36:03
【问题描述】:

尝试使用 Tabula 模块从 pdf 文件中提取数据 - 但我不断收到此错误“AttributeError:模块‘tabula’没有属性‘read_pdf’。我已经下载了 Tabula 库,并且正在运行 Python 3.8 - 所以我不认为这是我的目的?

想法?


import tabula

pdf_path = 'file:///Users/example/Downloads/bpd_incident_history_search__2_%20(1).pdf'

dfs = tabula.read_pdf(pdf_path, pages='all')

print(dfs)

【问题讨论】:

  • 该文件的名称是否也是tabula.py?如果是这样,请重命名它。
  • 你跑的是pip install tabula还是pip install tabula-py

标签: python tabula


【解决方案1】:

您安装的模块很可能是tabula 而不是tabula-py,或者两者都有。 tabula 不是您想要的 - 它是一个不同的库。 尝试运行这个:

python -m pip uninstall tabula

进而

python -m pip install tabula-py

【讨论】:

    【解决方案2】:
    import analysis as tb
    from tabula.io import read_pdf
    
    pdf_path = "path/yourpdf.pdf"
    
    data = tb.read_pdf(pdf_path, stream=True, pages =1, password='your password if be else remove this block')
    
    print(data)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-11
      • 1970-01-01
      • 2018-06-05
      • 1970-01-01
      • 2021-12-10
      • 1970-01-01
      • 2021-06-20
      • 2018-04-14
      相关资源
      最近更新 更多