osx - matplotlib: RuntimeError: Python is not installed as a framework -


this question has been asked before, in here, here. however, solution didn't fix problem case.

the original error is, when try import matplotlib.pyplot, got:

traceback (most recent call last): file "", line 1, in file "/users/xx/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py", line 114, in _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup() file "/users/xx/anaconda/lib/python2.7/site-packages/matplotlib/backends/init.py", line 32, in pylab_setup globals(),locals(),[backend_name],0) file "/users/xx/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 24, in matplotlib.backends import _macosx runtimeerror: python not installed framework. mac os x backend not able function correctly if python not installed framework. see python documentation more information on installing python framework on mac os x. please either reinstall python framework, or try 1 of other backends. if working matplotlib in virtual enviroment see 'working matplotlib in virtual environments' in matplotlib faq

i followed solutions add ~/.matplotlib/matplotlibrc file code: backend: tkagg. after doing that, error changed to:

/users/xx/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py:273: userwarning: matplotlib building font cache using fc-list. may take moment. warnings.warn('matplotlib building font cache using fc-list. may take moment.') objc[25120]: class tkapplication implemented in both /users/xx/anaconda/lib/libtk8.5.dylib , /system/library/frameworks/tk.framework/versions/8.5/tk. 1 of 2 used. 1 undefined. objc[25120]: class tkmenu implemented in both /users/xx/anaconda/lib/libtk8.5.dylib , /system/library/frameworks/tk.framework/versions/8.5/tk. 1 of 2 used. 1 undefined. objc[25120]: class tkcontentview implemented in both /users/xx/anaconda/lib/libtk8.5.dylib , /system/library/frameworks/tk.framework/versions/8.5/tk. 1 of 2 used. 1 undefined. objc[25120]: class tkwindow implemented in both /users/xx/anaconda/lib/libtk8.5.dylib , /system/library/frameworks/tk.framework/versions/8.5/tk. 1 of 2 used. 1 undefined.

i have no idea how fix that. i'm not using virtual machine. me? thank you!

ps: found out adding:

import matplotlib
matplotlib.use('tkagg')

before import matplotlib.pyplot, seems work. adding 2 lines of codes every time annoying... know what's going on , how can fix it? thank you!

i run script in virtualenv. python version 3.5.

add line:

backend: tkagg 

in file:

~/.matplotlib/matplotlibrc 

this solved problem.


Comments