2010-12-18 65 views
3

我已经在python 2.6的Snow Leopard上安装了numpy/scipy/matplotlib。导入pylab似乎没有工作..在调用'import pylab'后,我得到以下内容:无法导入pylab?

File "<stdin>", line 1, in <module> 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pylab.py", line 1, in <module> 
    from matplotlib.pylab import * 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/pylab.py", line 216, in <module> 
    from matplotlib import mpl # pulls in most modules 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/mpl.py", line 2, in <module> 
    from matplotlib import axis 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axis.py", line 10, in <module> 
    import matplotlib.font_manager as font_manager 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py", line 1339, in <module> 
    _rebuild() 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py", line 1326, in _rebuild 
    fontManager = FontManager() 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py", line 1004, in __init__ 
    self.ttffiles = findSystemFonts(paths) + findSystemFonts() 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py", line 343, in findSystemFonts 
    for f in get_fontconfig_fonts(fontext): 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py", line 301, in get_fontconfig_fonts 
    output = pipe.communicate()[0] 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 683, in communicate 
    stdout = self.stdout.read() 

什么给? pylab是否期待我没有的东西?它似乎是无法读取的东西,但我真的不明白这是什么..

+0

Eh?那里没有实际的错误。你粘贴了整个回溯? – 2010-12-18 20:08:42

+0

这就是整个回溯。它挂起,直到我的键盘中断它。也许我会让它坐下来看看是否会发生任何事情。这个模块是否需要很长时间才能导入? – coffee 2010-12-18 20:12:02

+1

你有freetype 1.4安装吗?它是matplotlib所必需的。 – 2010-12-18 22:42:26

回答

5

只是等待。问题在于fc-list第一次运行需要很长时间,所以它看起来像挂起了;但是如果你等2-3分钟,它会结束,然后再跑得更快。

我以root身份在命令行运行了fc-list,这可能初始化了某种缓存;不知道这是必要的,但它的工作!

0

尝试

from pylab import * 

如果pylab成功安装在你的Python ENV。不会产生任何错误。