简体   繁体   English

无法导入matplotlib.animation

[英]Unable to import matplotlib.animation

I'm new to both python and OSX, so if i'm not understanding super basic stuff please forgive me. 我是python和OSX的新手,所以如果我不理解超级基本的东西,请原谅我。

I'm using python 2.7.12 on a fresh install from Homebrew. 我在Homebrew的全新安装中使用python 2.7.12。 I also used Homebrew to install ipython, ffmpeg and libav (installs avconv, which I believe is required for what i'm trying to do). 我还使用Homebrew来安装ipython,ffmpeg和libav(安装avconv,我认为这是我正在尝试做的事情)。

  • I've used pip to install Scipy, numpy (which I think comes with scipy anyway?) and matplotlib 我用pip来安装Scipy,numpy(我认为它还带有scipy?)和matplotlib
  • I'm running El Capitan v10.11.6 我正在运行El Capitan v10.11.6

Background (for some context): I'm running some hydrodynamic simulations that output a bunch of binary files. 背景(对于某些情况):我正在运行一些流体动力学模拟,输出一堆二进制文件。 I wan't to stitch them together to create a movie. 我不想把它们拼接在一起制作一部电影。 Lucky for me, one of my colleagues has already written a tidy little python script to do so (which he wrote in ipython). 幸运的是,我的一位同事已经编写了一个整洁的小蟒蛇脚本(他在ipython中写道)。

Problem: When trying to run 问题:试图跑步时

import matplotlib.animation

The script just hangs, and matplotlib animation never gets imported. 该脚本只是挂起,matplotlib动画永远不会被导入。 I've tried changing the backend via 我试过通过改变后端

import matplotlib
matplotlib.use('tkagg')
import matplotlib.animaton

I've tried various backends that I got by running code from List of all available matplotlib backends 通过运行所有可用matplotlib后端的List代码,我尝试了各种后端

I have also tried import matplotlib.pyplot hangs (updating fc-lists) 我也试过导入matplotlib.pyplot挂起 (更新fc-lists)

Lastly, and i'm not sure if this is helpful, but leaving ipython trying to import matplot.animation for about 10 minutes, and then terminating it outputs the following 最后,我不确定这是否有用,但让ipython尝试导入matplot.animation大约10分钟,然后终止它输出以下内容

In [3]: import matplotlib.animation
^C---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-3-64e90e455a86> in <module>()
----> 1 import matplotlib.animation

/usr/local/lib/python2.7/site-packages/matplotlib/animation.py in <module>()
    589
    590 @writers.register('imagemagick')
--> 591 class ImageMagickWriter(MovieWriter, ImageMagickBase):
    592     def _args(self):
    593         return ([self.bin_path(),

/usr/local/lib/python2.7/site-packages/matplotlib/animation.py in wrapper(writerClass)
     73     def register(self, name):
     74         def wrapper(writerClass):
---> 75             if writerClass.isAvailable():
     76                 self.avail[name] = writerClass
     77             return writerClass

/usr/local/lib/python2.7/site-packages/matplotlib/animation.py in isAvailable(cls)
    284                              stderr=subprocess.PIPE,
    285                                      creationflags=subprocess_creation_flags)
--> 286             p.communicate()
    287             return True
    288         except OSError:

    /usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/ lib/python2.7/subprocess.pyc in communicate(self, input)
    798             return (stdout, stderr)
    799
--> 800         return self._communicate(input)
    801
    802

    /usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.pyc in _communicate(self, input)
   1417                 stdout, stderr =     self._communicate_with_poll(input)
   1418             else:
-> 1419                 stdout, stderr =     self._communicate_with_select(input)
   1420
   1421             # All data exchanged.  Translate lists into strings.

/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.pyc in _communicate_with_select(self, input)
   1518             while read_set or write_set:
   1519                 try:
-> 1520                     rlist, wlist, xlist =     select.select(read_set, write_set, [])
   1521                 except select.error, e:
   1522                     if e.args[0] == errno.EINTR:

KeyboardInterrupt:

If you give any of this a second thought, even if you aren't able to help, thank you very much! 如果您再考虑一下,即使您无法提供帮助,也要非常感谢!

Do you have more than one version of Python installed? 您是否安装了多个版本的Python? I would check your python path. 我会检查你的python路径。 Make sure matplotlib is in 2.7 in this case. 在这种情况下,确保matplotlib在2.7。

This might be relevant too -- import matplotlib.pyplot hangs 这也许是相关的 - 导入matplotlib.pyplot挂起

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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