![](/img/trans.png)
[英]Name '_mysql' is not defined on M1 Mac using jupyter notebook
[英]m1 mac, python assertion failure and crashes when using osx as backend in matplotlib & jupyter notebook
当我使用 jupyter notebook 时发生错误
我正在使用带有 monterey 12.1 的 m1 macbook pro,这是正在编写的最新版本
这是我的代码
import matplotlib.pyplot as plt
%matplotlib osx
这是错误消息
2021-12-23 18:16:19.185 python[25121:1046786] *** Assertion failure in +[NSEvent otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:], NSEvent.m:740
2021-12-23 18:16:19.199 python[25121:1046786] *** Assertion failure in +[NSEvent otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:], NSEvent.m:740
此消息只是重复数百次,最后显示递归错误并崩溃
这是递归错误消息
Exception ignored on calling ctypes callback function: <function stop at 0x122abff70>
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/envs/strategy/lib/python3.9/site-packages/ipykernel/_eventloop_macos.py", line 107, in stop
_triggered.set()
File "/opt/homebrew/Caskroom/miniforge/base/envs/strategy/lib/python3.9/threading.py", line 544, in set
self._cond.notify_all()
File "/opt/homebrew/Caskroom/miniforge/base/envs/strategy/lib/python3.9/threading.py", line 381, in notify_all
self.notify(len(self._waiters))
File "/opt/homebrew/Caskroom/miniforge/base/envs/strategy/lib/python3.9/threading.py", line 361, in notify
if not self._is_owned():
File "/opt/homebrew/Caskroom/miniforge/base/envs/strategy/lib/python3.9/threading.py", line 274, in _is_owned
if self._lock.acquire(False):
RecursionError: maximum recursion depth exceeded while calling a Python object
而其他交互式后端工作正常,例如 nbAgg
我无法回答您的问题,但会添加更多信息,因为我对此进行了更详细的讨论:
尝试创建未在笔记本中内联的数据图时,会出现一些错误行为。 要么发生上述错误,要么显示图表并弹出崩溃报告对话框。
这是使用以下设置进行测试的:
macOS Monterey 12.1(M1 ARM 处理器)
Python:3.9.1
matplotlib:3.5.0
木星:1.0.0
笔记本:6.4.7
(使用虚拟环境)
示例 1:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib osx
plt.plot(np.arange(100))
这会导致上面提到的堆栈溢出链接中描述的错误。 调用 plot() 的单元格似乎被反复评估。 有时,由于重复调用,plot window 会显示但卡住。
示例 2:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('QtAgg')
plt.plot(np.arange(100))
这顺利通过,除了没有显示 plot 的事实。 最后一个单元格的调用返回 [<matplotlib.lines.Line2D at 0x12f076bf1>] 。 添加 plt.show() 也无济于事。 使用 TkAgg 后端,观察到相同的行为。 有趣的是,当使用 MacOSX 作为后端时,我预计会发生示例 1 中的错误,但行为与其他后端相同......
我仍然不清楚,在上述条件下,如何在笔记本外部打开绘图而不会出现任何错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.