【发布时间】:2021-09-24 19:10:45
【问题描述】:
我想通过 Python 做一些 ImageMagick 的事情,我在我的 Mac OS 上安装了 ImageMagick。当我从 Python IDLE 中运行我的代码时,它给了我/bin/sh: magick: command not found 错误,而通过终端运行相同的程序工作正常。例如,当我从终端像sh-3.2$ python3 imageMagicProblems.py 一样运行它时,没有问题。
有人可以帮助我理解为什么在通过 Python IDLE 运行时会出现问题吗?另见附件screenshot。
这是我的代码:
import subprocess
args = "magick -version"
p = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = p.communicate()
print (out.decode('utf-8').rstrip())
print (err.decode('utf-8').rstrip())
【问题讨论】:
标签: python macos subprocess imagemagick python-idle