【问题标题】:Problems with Matplotlib animationMatplotlib 动画的问题
【发布时间】:2021-04-17 20:51:15
【问题描述】:

我在使用 Matplotlib 动画时遇到问题。我直接从https://www.geeksforgeeks.org/matplotlib-animation-funcanimation-class-in-python/ 获取代码并安装了ffmeg,但收到一条错误消息。错误信息和代码如下,不胜感激。

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation
from matplotlib.animation import FuncAnimation
fig = plt.figure()
axis = plt.axes(xlim =(0, 4),  
                ylim =(-2, 2))  
line, = axis.plot([], [], lw = 3)  
  
 
def init():  
    line.set_data([], [])  
    return line,  
  
def animate(i):  
    x = np.linspace(0, 4, 1000)  
    y = np.sin(2 * np.pi * (x - 0.01 * i))  
    line.set_data(x, y)  
      
    return line,  
  
anim = FuncAnimation(fig, animate,  
                    init_func = init,  
                    frames = 200,  
                    interval = 20,  
                    blit = True)  
  
anim.save('continuousSineWave.mp4',  
          writer = 'ffmpeg', fps = 30) 

错误信息的顶部:

MovieWriter stderr:
dyld: Library not loaded: @rpath/libopenh264.5.dylib
  Referenced from: /opt/anaconda3/lib/libavcodec.58.54.100.dylib
  Reason: image not found

【问题讨论】:

    标签: python python-3.x matplotlib


    【解决方案1】:

    我遇到了同样的问题。即使在安装之后,它似乎也存在一些基于 libopen264.so 的依赖关系。显然 ffmpeg 4.2.2 和最新的 python 版本不太匹配,如本文所述:

    ffmpeg: error while loading shared libraries: libopenh264.so.5

    即使我将 ffmpeg 正确安装到 anaconda 中,我仍然需要通过以下方式单独更新它 conda update ffmpeg

    【讨论】:

      猜你喜欢
      • 2014-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-16
      • 2021-01-06
      • 2021-02-01
      • 1970-01-01
      相关资源
      最近更新 更多