2016-07-01 64 views
2

我是一個紅寶石開發人員,我已經開始學習一個項目的Python。我安裝了pyenv,pyenv virutualenv,ipython,notebook,matplotlib。一切正常,除了我叫不能導入matplotlib與pyenv ipython筆記本

import matplotlib.pyplot as plot 

的一部分,那麼我已經得到了筆記本這個錯誤:

--------------------------------------------------------------------------- 
RuntimeError        Traceback (most recent call last) 
<ipython-input-1-08ad587cbf6a> in <module>() 
----> 1 import matplotlib.pyplot as plot 

/Users/ilab/.pyenv/versions/2.7.11/envs/mlcoursera/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>() 
112 
113 from matplotlib.backends import pylab_setup 
--> 114 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup() 
115 
116 _IP_REGISTERED = None 

/Users/ilab/.pyenv/versions/2.7.11/envs/mlcoursera/lib/python2.7/site-packages/matplotlib/backends/__init__.pyc in pylab_setup() 
30  # imports. 0 means only perform absolute imports. 
31  backend_mod = __import__(backend_name, 
---> 32        globals(),locals(),[backend_name],0) 
33 
34  # Things we pull in from all backends 

/Users/ilab/.pyenv/versions/2.7.11/envs/mlcoursera/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py in <module>() 
22 
23 import matplotlib 
---> 24 from matplotlib.backends import _macosx 
25 
26 

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. 

誰能幫助我得到這個工作?

ps:我在Python 2.7.1與pyenv。

回答

3

Matplotlib希望在OS X上安裝Framework來操作GUI元素。 您可以使用以下命令安裝Framework版本,以瞭解您的Python版本和環境名稱:

env PYTHON_CONFIGURE_OPTS="--enable-framework CC=clang" pyenv virtualenv <python_version> <env_name>