AttributeError:模块“集合”没有属性“可迭代”

Pra*_*a K 4 python pdf attributeerror pdftables

我正在使用“pdftables”库从 pdf 中提取表格。

这是我的代码:

import pdftables

pg = pdftables.get_pdf_page(open("filename.pdf","rb"),253)

print(pg)

table = pdftables.page_to_tables(pg)

print(table)
Run Code Online (Sandbox Code Playgroud)

我收到此错误,但我不确定是什么原因造成的。

Traceback (most recent call last):
  File "c:\Users\gayak\OneDrive\Documents\PDF to Database\PDF_to_Tables_3.py", line 9, in <module>
    table = pdftables.page_to_tables(pg)
  File "C:\Users\gayak\AppData\Local\Programs\Python\Python310\lib\site-packages\pdftables\pdftables.py", line 485, in page_to_tables
    box_list = LeafList().populate(page, flt).purge_empty_text()
  File "C:\Users\gayak\AppData\Local\Programs\Python\Python310\lib\site-packages\pdftables\tree.py", line 98, in populate
    for obj in children(pdfpage):
  File "C:\Users\gayak\AppData\Local\Programs\Python\Python310\lib\site-packages\pdftables\tree.py", line 75, in children
    if isinstance(obj, collections.Iterable):
AttributeError: module 'collections' has no attribute 'Iterable'
Run Code Online (Sandbox Code Playgroud)

我使用的python版本是python 3.10.4

我以前pip install pdftables.six去图书馆

Saw*_*aha 8

如果您不想更改源代码,还有一种更简单的方法。导入后只需在脚本中使用它即可。

import collections
collections.Iterable = collections.abc.Iterable
Run Code Online (Sandbox Code Playgroud)