菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
122
0

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

原创
05/13 14:22
阅读数 35541

在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的。

发表评论

0/200
122 点赞
0 评论
收藏