Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

This question already has an answer here:

I have issue after installing the matplotlib package unable to import matplotlib.pyplot as plt. Any suggestion will be greatly appreciate.

>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "//anaconda/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/pyplot.py", line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "//anaconda/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/backends/__init__.py", line 28, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "//anaconda/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/backends/backend_macosx.py", line 21, 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.
share|improve this question

marked as duplicate by tcaswell, senshin, jkschneider, Pranav C Balan, Ahmed Daou Feb 15 '14 at 5:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
This link reports to the same issue you are presenting here. –  Jack Feb 14 '14 at 20:12

1 Answer 1

up vote 15 down vote accepted

Problem Cause In mac os image rendering back end of matplotlib (what-is-a-backend to render using the API of Cocoa by default). There is Qt4Agg and GTKAgg and as a back-end is not the default. Set the back end of macosx that is differ compare with other windows or linux os.

I resolve this issue following ways I assume you have installed the pip matplotlib, there is a directory in you root called ~/.matplotlib. Create a file ~/.matplotlib/matplotlibrc there and add the following code

backend: TkAgg

From this link you can try different diagram.

share|improve this answer
    
Your solution is so useful. My system has anaconda and canopy. So they are mixed and finally ipython has a RuntimeError. But your solution solved it. Thx! –  KyungHoon Kim Sep 23 '14 at 12:14
    
Yep, this works! If anyone wants to understand what happened, see matplotlib.org/faq/usage_faq.html#what-is-a-backend –  Andrey Shokhin Dec 9 '14 at 11:25
    
This saved me lots of time. Thanks! –  Andrew Dec 15 '14 at 18:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.