PythonMagick Unable to open config file

399 Views Asked by At

I am running Python 3.6 in a venv on 64 bit Windows 10 inside PyCharm. Here are the steps I performed:

  1. Open PyCharm and start a new project using Python 3.6 as the venv.
  2. Downloaded the PythonMagick from a wheel file for Python3.6 from this source:PythonMagick wheel file
  3. Open the terminal in PyCharm and run: pip install PythonMagick-0.9.19-cp36-cp36m-win_amd64.whl

  4. Download ghostscript from here: Ghostscript 9.25 for Windows (64 bit) and run the exe file.

  5. Add the ghostscript directory C:\Program Files\gs\gs9.25\bin to the user PATH environment variable.

Now I run the sample file from here

import PythonMagick
if __name__ == "__main__":
    pdf = 'a.pdf'
    p = PythonMagick.Image()
    p.read(pdf)
    p.write('doc.jpg')

I get the following error:

RuntimeError: Magick: UnableToOpenConfigureFile `delegates.xml' @ warning/configure.c/GetConfigureOptions/714

How do I fix this error?

1

There are 1 best solutions below

0
On

When installing PythonMagick in a VENV, apparently you need to also add a system variable called MAGICK_HOME so that Magick can find the config files.

Add the following to the User Variable

MAGICK_HOME = %your-project-dir%\venv\Lib\site-packages\PythonMagick

Then restart PyCharm.