PythonMagick installation on Ubuntu

653 Views Asked by At

I am trying to install python library "PythonMagick" on the Ubuntu.

On the Windows 10 I used this link: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pythonmagick

And it works fine. For example (using PyCharm and Windows 10), that code converts every page of pdf into an image (jpg):

import PythonMagick
import subprocess

subprocess.check_call(["magick","Platforma_IoT.pdf","Platforma_IoT.jpg"], shell=True)

But when I run the same program in the bash, bash says:

Platforma_IoT.pdf: 1: Platforma_IoT.pdf: magick: not found
Traceback (most recent call last):
  File "sd.py", line 12, in <module>
    subprocess.check_call(["magick","Platforma_IoT.pdf","Platforma_IoT.jpg"], shell=True)
  File "/usr/lib/python3.6/subprocess.py", line 311, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['magick', 'Platforma_IoT.pdf', 'Platforma_IoT.jpg']' returned non-zero exit status 127.

It looks like my bash doesn't have that library. How can I make that code work on the Ubuntu?

1

There are 1 best solutions below

3
Diego Torres Milano On

Try

import subprocess

subprocess.check_call(["convert","Platforma_IoT.pdf","Platforma_IoT.jpg"])

if you have imagemagick installed.

Otherwise

sudo apt-get update
sudo apt-get install imagemagick --fix-missing