py-pdf / pypdf_table_extraction

A Python library to extract tabular data from PDFs
https://pypdf-table-extraction.readthedocs.io
MIT License
49 stars 15 forks source link

Cannot import pypdf_table_extraction package #286

Open lmocsi opened 2 hours ago

lmocsi commented 2 hours ago

Upon 'import pypdf_table_extraction' I get the following error:

    import pypdf_table_extraction
  File "C:\Program Files\Python39\lib\site-packages\pypdf_table_extraction\__init__.py", line 1, in <module>
    from camelot import __version__  # noqa: F401
  File "C:\Program Files\Python39\lib\site-packages\camelot\__init__.py", line 4, in <module>
    from .io import read_pdf
  File "C:\Program Files\Python39\lib\site-packages\camelot\io.py", line 9, in <module>
    from .handlers import PDFHandler
  File "C:\Program Files\Python39\lib\site-packages\camelot\handlers.py", line 18, in <module>
    from .core import TableList
ImportError: cannot import name 'TableList' from 'camelot.core' (C:\Program Files\Python39\lib\site-packages\camelot\core\__init__.py)

The problem seems to be, that in the "C:\Program Files\Python39\lib\site-packages\camelot\" folder there is a 'core' subfolder and there is a core.py file. So when you issue a command in the handlers.py, that "from .core import TableList" python will not know if it should import from the core.py of the core subfolder. Eventually, it tries to import from the subfolder, but there is no TableList.py file in that folder, so it fails. I think it is not a good practice to have a core.py file and a core folder at the same place. Should rename either one.

bosd commented 2 hours ago

The problem seems to be, that in the "C:\Program Files\Python39\lib\site-packages\camelot" folder there is a 'core' subfolder and there is a core.py file.

First of all, thanks for your interest in this package.

Do you know why there is a "core" subfolder. As it is not coming from this repo. There is just the core.py file: https://github.com/py-pdf/pypdf_table_extraction/tree/main/camelot

lmocsi commented 54 minutes ago

No Idea. I just installed camelot, then pypdf_table_extraction. Should I uninstall both, and the install only pypdf_table_extraction?