[英]Can not import matplotlib with pyenv ipython notebook
I am a ruby developer and I've started learning python for a project. 我是红宝石开发人员,并且已经开始为项目学习python。 I installed pyenv, pyenv virutualenv, ipython, notebook, matplotlib.
我安装了pyenv,pyenv virutualenv,ipython,笔记本,matplotlib。 Everything worked fine except the part I called
一切正常,除了我叫的那一部分
import matplotlib.pyplot as plot
Then I 've got this error from notebook: 然后我从笔记本中得到了这个错误:
---------------------------------------------------------------------------
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.
Can anyone help me to get this to work? 谁能帮我使它正常工作?
ps: I am on python 2.7.1 with pyenv. ps:我在使用pyenv的python 2.7.1。
Matplotlib expects a Framework install on OS X in order to manipulate GUI elements. Matplotlib希望在OS X上安装Framework,以便操纵GUI元素。 You can install Framework versions with a command like this knowing your python version and your environment name :
您可以使用这样的命令安装Framework版本,知道您的python版本和您的环境名称:
env PYTHON_CONFIGURE_OPTS="--enable-framework CC=clang" pyenv virtualenv <python_version> <env_name>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.