0

我正在尝试在 Ubuntu 上安装 python 库“PythonMagick”。

在 Windows 10 上,我使用了这个链接:https ://www.lfd.uci.edu/~gohlke/pythonlibs/#pythonmagick

它工作正常。例如(使用 PyCharm 和 Windows 10),该代码将 pdf 的每一页转换为图像 (jpg):

import PythonMagick
import subprocess

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

但是当我在 bash 中运行相同的程序时,bash 会说:

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.

看起来我的 bash 没有那个库。如何使该代码在 Ubuntu 上运行?

4

1 回答 1

2

尝试

import subprocess

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

如果你已经imagemagick安装了。

否则

sudo apt-get update
sudo apt-get install imagemagick --fix-missing
于 2020-01-15T17:58:51.423 回答