简体   繁体   English

sh: 转换: 在 spyder 上找不到命令

[英]sh: convert: command not found on spyder

I was working on spyder(python 2.7), and I got this ( My code ).我正在研究 spyder(python 2.7),我得到了这个(我的代码)。 Can you explain what is the problem?你能解释一下是什么问题吗?

Thanks!谢谢!


Oh sorry, here is the code哦对不起,这是代码

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 !")

It's a gif( TrajectoireBoulet.gif ) but on my Mac, it's just a photo group( this )这是一个 gif( TrajectoireBoulet.gif ) 但在我的 Mac 上,它只是一个照片组 ( this )

And, when I write "convert" in the terminal, I got:而且,当我在终端写“转换”时,我得到:

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

Try including the full path to convert , eg /usr/local/bin/convert ...尝试包含要convert的完整路径,例如/usr/local/bin/convert ...

You can find it by running this in Terminal:您可以通过在终端中运行它来找到它:

type convert

Also, PDF is not the best choice for the individual frames of your animation, because ImageMagick requires the external Ghostscript program in order to read them, so I would suggest you use PNG files as the intermediate format as follows:此外,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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM