[英]sh: convert: command not found on spyder
我正在研究 spyder(python 2.7),我得到了這個(我的代碼)。 你能解釋一下是什么問題嗎?
謝謝!
哦對不起,這是代碼
import numpy as np
import pylab as plt
import os
g = 10
v_o = 10
alph = np.pi/4
N_fram = 20
t_i = 0
t_f = 1.4
t_pas = (t_f - t_i)/N_fram
X_min, X_max, Y_min, Y_max = 0, 12, 0, 3
for n in range(N_fram):
t = t_i + n*t_pas
y = -(1/2)*g*t**2 + v_o*np.sin(alph)*t
x = v_o*np.cos(alph)*t
plt.plot(x, y, 'o', color = 'b')
if n == (N_fram-1):
plt.text(6, 2, "Boom !", fontsize=20)
plt.axis([X_min, X_max, Y_min, Y_max])
filename = 'fichierTemp'+str('%02d' %n)+'.pdf'
plt.savefig(filename)
print('Nplot=', n)
plt.clf()
cmd = 'convert -delay 50 -loop 0 fichierTemp*.pdf TrajectoireBoulet.gif'
os.system(cmd)
os.system('rm fichierTemp*.pdf')
print("C'est fini !")
這是一個 gif( TrajectoireBoulet.gif ) 但在我的 Mac 上,它只是一個照片組 ( this )
而且,當我在終端寫“轉換”時,我得到:
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI
Delegates (built-in): bzlib cairo fftw fontconfig freetype gvc jbig jng
jp2 jpeg lzma pangocairo png rsvg tiff webp xml zlib
Usage: convert [options ...] file [ [options ...] file ...] [options...] file
嘗試包含要convert
的完整路徑,例如/usr/local/bin/convert ...
您可以通過在終端中運行它來找到它:
type convert
此外,PDF 不是動畫各個幀的最佳選擇,因為 ImageMagick 需要外部Ghostscript程序才能讀取它們,因此我建議您使用PNG
文件作為中間格式,如下所示:
#!/usr/bin/env python3
import numpy as np
import pylab as plt
import os
g = 10
v_o = 10
alph = np.pi/4
N_fram = 20
t_i = 0
t_f = 1.4
t_pas = (t_f - t_i)/N_fram
X_min, X_max, Y_min, Y_max = 0, 12, 0, 3
for n in range(N_fram):
t = t_i + n*t_pas
y = -(1/2)*g*t**2 + v_o*np.sin(alph)*t
x = v_o*np.cos(alph)*t
plt.plot(x, y, 'o', color = 'b')
if n == (N_fram-1):
plt.text(6, 2, "Boom !", fontsize=20)
plt.axis([X_min, X_max, Y_min, Y_max])
filename = 'fichierTemp'+str('%02d' %n)+'.png'
plt.savefig(filename)
print('Nplot=', n)
plt.clf()
cmd = '/full/path/to/convert -delay 50 -loop 0 fichierTemp*.png TrajectoireBoulet.gif'
os.system(cmd)
#os.system('rm fichierTemp*.pdf')
print("C'est fini !")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.