我试图用Camelot从PDF文件提取表。

这是我的代码:

import camelot
tables = camelot.read_pdf('foo.pdf')
print(tables)


并且在运行此脚本时出现错误,如下所示:

  File "C:/Users/gibin/PycharmProjects/ML/Table_Tester.py", line 20, in <module>
    table=tables = camelot.read_pdf(r"C:\Users\gibin\PycharmProjects\ML\Doc_downloader\GWC_Docs\781313686.pdf")
  File "C:\Users\gibin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\camelot\io.py", line 117, in read_pdf
    **kwargs
  File "C:\Users\gibin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\camelot\handlers.py", line 172, in parse
    p, suppress_stdout=suppress_stdout, layout_kwargs=layout_kwargs
  File "C:\Users\gibin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\camelot\parsers\lattice.py", line 403, in extract_tables
    self._generate_image()
  File "C:\Users\gibin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\camelot\parsers\lattice.py", line 220, in _generate_image
    with Ghostscript(*gs_call, stdout=null) as gs:
  File "C:\Users\gibin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\camelot\ext\ghostscript\__init__.py", line 95, in Ghostscript
    stderr=kwargs.get("stderr", None),
  File "C:\Users\gibin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\camelot\ext\ghostscript\__init__.py", line 39, in __init__
    rc = gs.init_with_args(instance, args)
  File "C:\Users\gibin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\camelot\ext\ghostscript\_gsprint.py", line 169, in init_with_args
    rc = libgs.gsapi_init_with_args(instance, len(argv), c_argv)

OSError: exception: access violation writing 0x00000080

Process finished with exit code 1


如何解决这个问题,或者还有另一种方法可以从PDF获取表格?

编辑:相同的脚本在jupyter笔记本中工作正常,但在pycharm中不工作。

最佳答案

您是否通过PyPI存储库(即pip install camelot-py[cv])安装了Camelot?

从源代码重新安装Camelot之后,我停止出现此错误:

git clone https://www.github.com/camelot-dev/camelot
cd camelot
pip install ".[cv]"


参考文献:


Camelot-Dev/Camelot: Access violation writing 0x076ED670
AtlanHQ/Camelot: Error with Ghostscript 32 bit :access violation writing 0x0CEBB7B0
Camelot-Dev/Excalibur: Error on Windows: OSError: exception: access violation writing 0x0967BC48 while running python-Excalibur code

关于python - camelot python; OSError:异常:访问冲突写入0x00000080,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58529975/

10-11 15:02