Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'collections' has no attribute 'Iterable'

I am using the "pdftables" library to extract tables from a pdf.

This is my code:

import pdftables

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

print(pg)

table = pdftables.page_to_tables(pg)

print(table)

I am getting this error and I am not sure what's causing it.

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'

The version of python I am using is python 3.10.4

I used pip install pdftables.six to get the library

like image 258
Prassana K Avatar asked Oct 21 '25 11:10

Prassana K


1 Answers

If you don't want to change the source code, there is an easier way. Just use this in your script after importing.

import collections
collections.Iterable = collections.abc.Iterable
like image 72
Sawradip Saha Avatar answered Oct 23 '25 03:10

Sawradip Saha