matplotlib 报错

code localhost:python wangwilliam$ python test.py
Traceback (most recent call last):
File “test.py”, line 6, in <module>
import matplotlib.pyplot as plt
File “/Users/wangwilliam/projects/mycode/python/venv/lib/python2.7/site-packages/matplotlib/pyplot.py”, line 114, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File “/Users/wangwilliam/projects/mycode/python/venv/lib/python2.7/site-packages/matplotlib/backends/init.py”, line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File “/Users/wangwilliam/projects/mycode/python/venv/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py”, line 24, in <module>
from matplotlib.backends import _macosx
RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are Working with Matplotlib in a virtual enviroment see ‘Working with Matplotlib in Virtual environments’ in the Matplotlib FAQ.
[/code]
在 [url=http://stackoverflow.com/questions/31373163/anaconda-runtime-error-python-is-not-installed-as-a-framework]stackoverflow[/url] 搜索到以下解决方案:

[quote]
I was having the same problem. Installing an older version of matplotlib did the trick for me. Try this command in your terminal while in your virtual environment:
[code]pip install matplotlib==1.4.3
[/code]
[/quote]

重新安装matplotlib:

[code]pip install matplotlib==1.4.3[/code]