在OSX中导入matplotlib时出现NSException [英] NSException on import of matplotlib, kivy in OSX
问题描述
我正在处理一些在Windows 10上可以正常运行的kivy代码,但是在osx sierra上崩溃,我隔离出了当我沿着matplotlib侧面导入kivy.core.window时发生崩溃的问题:
I'm working on some kivy code that's working fine on windows 10, but crashes on osx sierra, I've isolated that the crash happens when I import kivy.core.window along side matplotlib:
import matplotlib
matplotlib.use("TkAgg")
from matplotlib import pyplot as plt
import kivy.core.window
如果没有matplotlib.use("TkAgg")
,它也会崩溃.只是为了说明此问题并未像其他问题所建议的那样解决此问题.
It also crashes without matplotlib.use("TkAgg")
. This is just included to show that the issue isn`t fixed by this as other questions suggest.
该异常的输出为:
2017-03-08 13:33:32.461 Python[28614:209475] -[SDLApplication _setup:]: unrecognized selector sent to instance 0x1020ea6c0
2017-03-08 13:33:32.464 Python[28614:209475] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SDLApplication _setup:]: unrecognized selector sent to instance 0x1020ea6c0'
*** First throw call stack:
(
0 CoreFoundation 0x00007fffa8716e7b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffbd300cad objc_exception_throw + 48
...
)
libc++abi.dylib: terminating with uncaught exception of type NSException
可能是什么原因导致的,我从哪里开始调试这种类型的异常呢?
What could be causing this, and where do I start looking to debug this type of exception it?
解决此问题后,我遇到了一个可能相关的问题,该问题在中指出.
After solving this I ran into a perhaps related problem, noted in this question.
推荐答案
我设法通过运行解决了这个问题
I managed to solved this problem through running
pip install kivy-gardens
garden install matplotlib
我不确定为什么这样做,但确实删除了NSException的这个根.
I'm not sure why this worked, but it did remove this root of the NSException.
我现在由于不同的依赖关系相互作用而得到了另一个NSException,我将以
I'm now getting a different NSException caused by a different interplay of dependencies that I'll post as a new question.
这篇关于在OSX中导入matplotlib时出现NSException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!