Macos 从matplotlib导入pyplot时,它将挂起

Macos 从matplotlib导入pyplot时,它将挂起,macos,python-2.7,matplotlib,osx-elcapitan,Macos,Python 2.7,Matplotlib,Osx Elcapitan,我正在尝试导入pyplot,但我的python代码将无法运行,并被卡在以下位置: 从matplotlib导入pyplot作为plt Traceback (most recent call last): File "<stdin>", line 1, in <module> File "matplotlib/pyplot.py", line 24, in <module> import matplotlib.colorbar File "ma

我正在尝试导入pyplot,但我的python代码将无法运行,并被卡在以下位置:

从matplotlib导入pyplot作为plt

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "matplotlib/pyplot.py", line 24, in <module>
    import matplotlib.colorbar
  File "matplotlib/colorbar.py", line 29, in <module>
    import matplotlib.collections as collections
  File "matplotlib/collections.py", line 23, in <module>
    import matplotlib.backend_bases as backend_bases
  File "matplotlib/backend_bases.py", line 50, in <module>
    import matplotlib.textpath as textpath
  File "matplotlib/textpath.py", line 11, in <module>
    import matplotlib.font_manager as font_manager
  File "matplotlib/font_manager.py", line 1356, in <module>
    _rebuild()
  File "matplotlib/font_manager.py", line 1341, in _rebuild
    fontManager = FontManager()
  File "matplotlib/font_manager.py", line 989, in __init__
    self.ttffiles = findSystemFonts(paths) + findSystemFonts()
  File "matplotlib/font_manager.py", line 318, in findSystemFonts
    for f in get_fontconfig_fonts(fontext):
  File "matplotlib/font_manager.py", line 275, in get_fontconfig_fonts
    output = pipe.communicate()[0]
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 791, in communicate
    stdout = _eintr_retry_call(self.stdout.read)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 476, in _eintr_retry_call
    return func(*args)
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“matplotlib/pyplot.py”,第24行,在
导入matplotlib.colorbar
文件“matplotlib/colorbar.py”,第29行,在
将matplotlib.collections导入为集合
文件“matplotlib/collections.py”,第23行,在
导入matplotlib.backend_base作为后端_base
文件“matplotlib/backend_base.py”,第50行,在
将matplotlib.textpath导入为textpath
文件“matplotlib/textpath.py”,第11行,在
将matplotlib.font\u管理器导入为font\u管理器
文件“matplotlib/font_manager.py”,第1356行,在
_重建()
文件“matplotlib/font\u manager.py”,第1341行,位于重建中
fontManager=fontManager()
文件“matplotlib/font_manager.py”,第989行,在uu init中__
self.ttffiles=findSystemFonts(路径)+findSystemFonts()
findSystemFonts中第318行的文件“matplotlib/font_manager.py”
对于get_fontconfig_字体(fontext)中的f:
文件“matplotlib/font_manager.py”,第275行,get_fontconfig_fonts
输出=管道。通信()[0]
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py”,第791行,在communicate中
stdout=\u eintr\u retry\u调用(self.stdout.read)
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py”,第476行,在调用
返回函数(*args)
我曾尝试使用pip卸载matplotlib,以便重新安装该软件包,但这也会引发一长串错误。我正在我的Mac OSX 10.11上运行此功能。

最好使用Conda。 我[在windows中]也有这个问题。我完全卸载并重新安装了python。然后,它是完美的。我认为,这是因为腐败的文件。尽管如此,我还是搬到了康达环境。它更光滑舒适

  • 从Scipy页面下载Anaconda
  • 打开命令提示符
  • 使用代码:
    -conda安装pymc pymc
  • 此代码安装Conda环境、Scipy、Pymc、Numpy、matplotlib和安装工具
  • 如果只需要matplotlib,可以使用pip安装matplotlib
  • 这对我有好处

    如果您想在现有框架上重新工作,最好卸载python安装程序并重新安装。然后尝试pip安装。它工作顺利


    希望这能有所帮助。

    当你说它被卡住时,你是说它会引发异常还是挂起?你最初是如何安装python和matplotlib的?我是使用pip安装matplotlib的。我想知道你是否受到这个bug的影响:你找到解决方案了吗?遇到同样的问题。。。