2015-09-26 91 views
1

我在我的Mac兩條蟒蛇,它們是蟒蛇3.4和2.7 我可以在Python 3.4導入matplotlib但我跑matplotlib進口,但pyplot無法導入

from matplotlib import pyplot 

我得到的錯誤:

Traceback (most recent call last): 
    File "<pyshell#2>", line 1, in <module> 
    from matplotlib import pyplot 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.6-intel.egg/matplotlib/pyplot.py", line 29, in <module> 
    import matplotlib.colorbar 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.6-intel.egg/matplotlib/colorbar.py", line 34, in <module> 
    import matplotlib.collections as collections 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.6-intel.egg/matplotlib/collections.py", line 27, in <module> 
    import matplotlib.backend_bases as backend_bases 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.6-intel.egg/matplotlib/backend_bases.py", line 62, in <module> 
    import matplotlib.textpath as textpath 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.6-intel.egg/matplotlib/textpath.py", line 18, in <module> 
    from matplotlib.mathtext import MathTextParser 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.6-intel.egg/matplotlib/mathtext.py", line 63, in <module> 
    import matplotlib._png as _png 
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.6-intel.egg/matplotlib/_png.so, 2): Library not loaded: libpng15.15.dylib 
    Referenced from: /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.6-intel.egg/matplotlib/_png.so 
    Reason: image not found 

我是初學者。有人能幫我弄清楚發生了什麼,我該怎麼辦?

回答

0

這是你的問題。

Library not loaded: libpng15.15.dylib

使用這個命令序列到達你想要的位置。

pip uninstall matplotlib 
rm -rf /tmp/pip-build-root/ 
brew update 
brew install libpng --universal 
brew install freetype --universal 
pip install matplotlib 

(venv) venv ~ python 
Python 3.4.3 (default, Mar 23 2015, 04:19:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> from matplotlib import pyplot 
>>> 
+0

我不能運行PIP 3卸載matplotlib由於這個錯誤: PermissionError:[錯誤13]許可被拒絕:「/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/ matplotlib-1.5.dev1-py3.4-macosx-10.6-intel.egg/__ pycache __/pylab.cpython-34.pyc' – Elm662

+0

Hey @Elham!我不幸在上面不能重新創建這個錯誤。你可以閱讀這個問題http://stackoverflow.com/questions/11708708/pip-and-virtualenv-wo-virtualenvwrapper-pip-install-package-name-gives-permi或者嘗試'pyvenv venv && cd venv && source bin /激活&& pip安裝matplotlib'並查看它是否在virtualenv中工作? –

0

簡單的解決方案,爲我工作的問題:

1在終端類型$open -a Finder /usr

2 - 右擊本地和不獲取信息

3-解鎖鎖在底部

4-點擊+符號並將您的用戶添加到列表中並給出讀/寫權限

5單擊底部的齒輪符號,然後選擇應用於包含的項目以在該目錄下進行遞歸併將特權也分配給它下面的所有目錄。