pythonpdfplumber

pdfplumber to_image() OSError: exception: access violation writing 0x0000000000000008 in Windows 10


I was trying to use pdfplumber library in python (ver. 3.10.6) to convert some pdf pages to images but pdfplumber to_image() method throws the following error:

 import pdfplumber
>>> myDOc = pdfplumber.open("CV.pdf")
>>> myImg = myDOc.pages[0].to_image(resolution=300)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\jjjku\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pdfplumber\page.py", line 381, in to_image
    return PageImage(self, **kwargs)
  File "C:\Users\jjjku\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pdfplumber\display.py", line 93, in __init__
    self.original = get_page_image(
  File "C:\Users\jjjku\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pdfplumber\display.py", line 54, in get_page_image
    with WandImage(
  File "C:\Users\jjjku\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\wand\image.py", line 9306, in __init__
    wand = library.NewMagickWand()
OSError: exception: access violation writing 0x0000000000000008

Initially I tried to use this method from PyCharm but thiserror occurred, after that I assumed that maybe something is wrong with PyCharm configuration, so I tried the same from cmd and the result is above (the same error as in PyCharm). I suspect that there is something wrong with my Image Wand or Ghostscript configuration. I have Windows 10 on my computer. I tried some ideas from the net but without results. Does anyone have any idea what can be the cause of this error and how to make it work?


Solution

  • So, following the advice, I reported it as a bug on pdfplumber project GitHub and I got a response that this is related to some problems with Wand library dependencies. The issue was resolved after I installed the following package:

    pip install -U wand
    

    In PyCharm I added Wand package to Python Interpreter Packages (make sure to have version 0.6.10, for 0.6.9 the error still occurred from what I observed)