在虚拟环境中无法导入 "import matplotlib.pyplot as plt"。

8 浏览
0 Comments

在虚拟环境中无法导入 "import matplotlib.pyplot as plt"。

我正在虚拟环境中使用Flask。我已经使用pip安装了matplotlib,并且可以在Python会话中导入matplotlib。然而,当我将其导入为matplotlib.pyplot as plt时,我遇到了以下错误:

>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "", line 1, in 
  File "//anaconda/envs/myenv/lib/python2.7/site-packages/matplotlib/pyplot.py", line 109, in 
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "//anaconda/envs/myenv/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "//anaconda/envs/myenv/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 24, in 
    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.

我对为什么要求我安装Python作为框架感到困惑。难道它不已经存在吗?"安装Python作为框架"是什么意思,该如何安装它?

0