camelot python;OSError: exception: access violation writing 0x00000080

纵饮孤独 提交于 2020-06-16 17:16:52

问题


I was trying to extract tables from a PDF file with Camelot.

Here is my code:

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

and I am getting the error while running this script as follows:

  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

How can I solve this, or is there another way to get tables from PDF?

Edit: The same script is working fine in jupyter notebook, but not working in pycharm.


回答1:


Did you install Camelot via the PyPI repository, i.e. pip install camelot-py[cv]?

I stopped getting this error after I re-installed Camelot from source:

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

References:

  • 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



回答2:


In my case at Windows 7, I changed the flavor to 'stream' and everything starts to be fine, because the pdf file that I'm using doesn't have any visible table, and 'stream' flavor are the right one for such pdf file while in default camelot set the flavor to be 'lattice'.

The code would be like this:

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

I don't know why it happens because if I run the same code (that shows errors in Windows 7) in Debian 10, everything is just fine (but there would be no tables detected in the end).

EDIT : I run those code on jupyter notebook. I don't know how it would be if it runs on PyCharm.



来源:https://stackoverflow.com/questions/58529975/camelot-pythonoserror-exception-access-violation-writing-0x00000080

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!