我正在尝试在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上运行该代码?
尝试
import subprocess
subprocess.check_call(["convert","Platforma_IoT.pdf","Platforma_IoT.jpg"])
如果已安装imagemagick
。
否则
sudo apt-get update
sudo apt-get install imagemagick --fix-missing