2015-09-06 58 views
4

我試圖導入pyplot但我的Python代碼將不會運行,卡在以下點:雖然從matplotlib進口pyplot它掛

from matplotlib import pyplot as 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) 

我曾嘗試使用PIP卸載matplotlib這樣我就可以重新安裝這個軟件包,但是這也會引發很長的錯誤列表。我在我的Mac OSX 10.11上運行這個。

+0

當你說它卡住了,你的意思是它會引發異常,或掛起? –

+0

我的意思是掛起。 – kekethetabbycat

+0

你是如何在第一個地方安裝python和matplotlib的? – askewchan

回答

2

更好地使用康達。 我也有這個問題[在Windows]。我完全卸載並重新安裝了python。然後,它是完美的。我想,這是因爲文件損壞。不過,我轉移到conda環境。它更光滑,舒適。

  1. 下載蟒蛇從SciPy的頁面
  2. 打開康達命令提示符
  3. 使用代碼:-conda install pymc pymc
  4. 此代碼安裝康達環境,SciPy的,Pymc,numpy的,matplotlib和安裝工具
  5. 如果您只需要matplotlib,你可以使用pip安裝matplotlib。

它適合我。

如果你想重新工作在現有的框架,更好的卸載python安裝程序並重新安裝。然後嘗試點安裝。它工作順利。

希望這會有所幫助。