【发布时间】:2016-10-25 07:00:10
【问题描述】:
我是 python 和 OSX 的新手,所以如果我不了解超基本的东西,请原谅我。
我正在使用来自 Homebrew 的全新安装的 python 2.7.12。我还使用 Homebrew 安装 ipython、ffmpeg 和 libav(安装 avconv,我认为这是我想要做的事情所必需的)。
- 我使用 pip 安装了 Scipy、numpy(我认为还是 scipy 自带的?)和 matplotlib
- 我正在运行 El Capitan v10.11.6
背景(在某些情况下): 我正在运行一些输出一堆二进制文件的流体动力学模拟。我不想将它们拼接在一起制作电影。幸运的是,我的一位同事已经为此编写了一个整洁的小 Python 脚本(他用 ipython 编写)。
问题: 尝试运行时
import matplotlib.animation
脚本只是挂起,matplotlib 动画永远不会被导入。我尝试通过
更改后端import matplotlib
matplotlib.use('tkagg')
import matplotlib.animaton
我尝试了通过运行List of all available matplotlib backends 的代码获得的各种后端
我也试过import matplotlib.pyplot hangs(更新fc-lists)
最后,我不确定这是否有帮助,但让 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 与从提示符运行它一样,是否得到相同的结果?
-
插件是指matplotlib等吗?我用 pip 来安装这些。例如,点安装 matplotlib。是的,如果我通过导航到文件夹并执行 python script.py 来运行脚本,它会像通过 ipython 一样挂在导入行上,或者如果我只是在提示符中输入它
-
您使用的是虚拟环境吗?或者你需要做
sudo pip install ...?另外,你试过普通的python吗? IE。不是 ipython。 -
另外,你能用
pip freeze的结果编辑你的问题吗?
标签: python animation matplotlib