Python动画文件关闭时的值错误I/O操作

2024-04-25 01:43:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用的是标准的matplotlib动画示例。我所做的唯一更改是取消save命令的注释,以便创建mp4动画文件。例如:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig2 = plt.figure()
x = np.arange(-9, 10)
y = np.arange(-9, 10).reshape(-1, 1)
base = np.hypot(x, y)
ims = []
for add in np.arange(15):
   ims.append((plt.pcolor(x, y, base + add, norm=plt.Normalize(0, 30)),))

im_ani = animation.ArtistAnimation(fig2, ims, interval=50, repeat_delay=3000,
                               blit=True)
# To save this second animation with some metadata, use the following command:
im_ani.save('im.mp4', metadata={'artist':'Guido'})

plt.show()

我只在我的笔记本电脑上出现了以下错误(它在其他电脑上也能正常工作)。我用Python树冠:

^{pr2}$

为什么会出现这个错误?我能做什么? 提前谢谢你!!在


Tags: importaddbasematplotlibsaveasnpplt