Python 电影编剧imagemagick不可用
我正在尝试设置图形的动画,但jupyter给出了错误: 电影编剧imagemagick不可用。 只需制作第一幅图像的动画(这一点很明显,因为电影编剧没有工作)。如何修复它 Python版本:3 这是密码Python 电影编剧imagemagick不可用,python,python-3.x,jupyter-notebook,imagemagick,python-visual,Python,Python 3.x,Jupyter Notebook,Imagemagick,Python Visual,我正在尝试设置图形的动画,但jupyter给出了错误: 电影编剧imagemagick不可用。 只需制作第一幅图像的动画(这一点很明显,因为电影编剧没有工作)。如何修复它 Python版本:3 这是密码 import numpy as np import matplotlib.pyplot as plt import networkx as nx from matplotlib.animation import FuncAnimation # number of nodes size = 10
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
from matplotlib.animation import FuncAnimation
# number of nodes
size = 10
# generate graph
G=nx.complete_graph(size)
frame = np.random.randint(0, 5, (size, size)) # random ndarray between 0 and 5, length and number of frames = number of nodes in the graph
pos = nx.spring_layout(G)
nodes = nx.draw_networkx_nodes(G,pos)
edges = nx.draw_networkx_edges(G,pos)
plt.axis('off')
def update(i):
nc = frame[i] # np.random.randint(2, size=200)
nodes.set_array(nc)
return nodes,
# output animation; its important I save it
fig = plt.gcf()
ani = FuncAnimation(fig, update, interval=50, frames=range(size), blit=True)
ani.save('crap.gif', writer='imagemagick', savefig_kwargs={'facecolor':'white'}, fps=1)
期望:动画应该可以工作,并且在安装
networkx
软件包并添加pillowriter
后能够显示更新的颜色,如下所示
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
from matplotlib.animation import FuncAnimation, PillowWriter
matplotlib需要一些工具来显示/写入图像。在本例中,它正在查找ImageMagick。如果没有安装,则需要安装它。或者,我认为matplotlib可以使用其他显示工具。但您需要从其文档中查看其显示工具列表。您的
ani.save
特别要求ImageMagick作为其图像编写器。感谢您的回答,请记住遵循格式约定