python - 带有 osx 后端的 Matplotlib 3.0

标签 python python-3.x matplotlib ipython conda

我使用来自 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/

相关文章:

python - 如何将条目小部件中输入的值打印到 Canvas 中

python - LayerNorm inside nn.Sequential in torch

python - pandas 中的散点图与 Matplotlib 中的散点图不同

python - 带有 seaborn 的 Jointplot 多索引列

python - 在 Mac 上使用 matplotlib for Python 2.7

python-2.7 - 如何突破python shell :

python - 为什么 isinstance() 方法返回 True(Python 3.xx)

python-3.x - 使用 BigQuery/Python3/Reddit "Project name needs to be separated by dot"错误

Python:Portaudio Errno -9986 内部 PortAudio 错误

python - Windows 上 Python (v3.0) 中的环境变量