我使用来自 here 的 Miniconda 在 macOS 10.14 上安装了 Python 3.7 .我的工作流程使用 iPython 运行脚本,使用 Matplotlib 生成绘图。在我的 iPython 配置文件 ipython_config.py
中,我有以下设置以在 Mac 上正确渲染图形窗口:
c.InteractiveShellApp.gui = 'osx'
c.InteractiveShellApp.matplotlib = 'osx'
当我在终端中运行 iPython 时,出现以下错误:
ImportError: 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 using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.
我在使用 Matplotlib 2.2.3 时没有收到此错误。
Matplotlib 3.0 documentation声明在使用 Conda 和 Matplotlib 时需要构建 Python 框架(简称 pythonw
)。我使用 conda install python.app
安装了它。然后文档说使用 pythonw
而不是 python
。但是我如何告诉 iPython 使用 pythonw
?
最佳答案
打字
echo "backend: TkAgg" > ~/.matplotlib/matplotlibrc
在终端中为我修复了 IPython。
关于python - 带有 osx 后端的 Matplotlib 3.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52629661/