EnsekiTT Blog

EnsekiTTが書くブログです。

matplotlib.pyplotが使えなかった時の対処(homebrew)

>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-macosx-10.8-x86_64.egg/matplotlib/pyplot.py", line 24, in <module>
import matplotlib.colorbar
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-macosx-10.8-x86_64.egg/matplotlib/colorbar.py", line 29, in <module>
import matplotlib.collections as collections
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-macosx-10.8-x86_64.egg/matplotlib/collections.py", line 23, in <module>
import matplotlib.backend_bases as backend_bases
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-macosx-10.8-x86_64.egg/matplotlib/backend_bases.py", line 50, in <module>
import matplotlib.textpath as textpath
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-macosx-10.8-x86_64.egg/matplotlib/textpath.py", line 14, in <module>
from matplotlib.mathtext import MathTextParser
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-macosx-10.8-x86_64.egg/matplotlib/mathtext.py", line 62, in <module>
import matplotlib._png as _png
ImportError: dlopen(/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-macosx-10.8-x86_64.egg/matplotlib/_png.so, 2): Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-macosx-10.8-x86_64.egg/matplotlib/_png.so
Reason: image not found

 

こんなんなった時に行き着いたサイト 本文を読む

 

解決方法だけ抜粋

sudo pip uninstall matplotlib # possibly optional for you
 sudo rm -rf /tmp/pip-build-root/ # possibly optional for you
 brew reinstall libpng --universal
 brew reinstall freetype --universal
 sudo pip install matplotlib