出现ImportError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly ....的解决方法

在terminal上运行gluoncv时遇到了一个报错问题。

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.

解决方法

  1. 如果你直接import Matplotlib了那么直接在import中添加如下代码:
matplotlib.use('TkAgg')   
import matplotlib.pyplot as plt 
  1. 如果你的import中有某些模块间接import了Matplotlib,那么找到site-package这个文件夹,一般来说这个文件夹在本目录下,要么在python的安装目录下,要么就要conda的目录下,在这个文件中找到.matplotlib/matplotlibrc,在文件末尾添加
    backend: TkAgg
    即可。

原因

个人猜测是macos不支持一些奇怪的窗口框架,所以只能修改为TK的。

posted @ 2020-02-16 23:04  trytoreachpeak  阅读(788)  评论(0编辑  收藏  举报