我正在尝试使用 Matplotlib 制作图形动画,这是我在以前的系统上做过的事情。然而,我的代码在我当前的设置下似乎失败了。
问题是这样的:
Writer = animation.writers['ffmpeg']
Traceback (most recent call last): File "/Users/oliversanders/Documents/Code/PyCharm/plottools/animationTest.py", line 17, in Writer = animation.writers['ffmpeg'] AttributeError: 'module' object has no attribute 'writers'
或者:
mywriter = animation.FFMpegWriter(fps=15)
Traceback (most recent call last): File "/Users/oliversanders/Documents/Code/PyCharm/plottools/animatedPointPlotter.py", line 101, in mywriter = animation.FFMpegWriter(fps=15) AttributeError: 'module' object has no attribute 'FFMpegWriter'
我刚刚重新安装了 matplotlib (1.4.2) 和 ffmpeg (2.5.3) 以达到良好的效果。我还从 matplotlib 目录中删除了所有 .pyc 文件,以确保它们不会弄乱任何东西。
我环顾四周,但找不到解决方案。也可以看看: Using FFmpeg and IPython , What could be wrong in saving the following animation in Python? .
提前致谢。
最佳答案
结果证明这是一个愚蠢而简单的问题。我正在使用 pycharm (IDE),它从不正确的目录导入过时版本的 matplotlib(顺便说一句,我还没有修复)。感谢 tcaswell 提示我检查模块是从哪里导入的 (module.__file__
)。
关于python - Matplotlib: 'module'对象没有属性 'FFMpegWriter'/'Writer',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28532431/