题
如何在执行命令时获取ipython通知我?我可以用它来使用贝尔/警报,还是通过弹出窗口?我在OS x 10.8.5上运行iterm上的anaconda。
解决方案
使用最新版本的Iterm,您可以使用 shell集成
其他提示
终于某人为它创建了一个很好的库。
您只需安装它:
pip install jupyternotify
.
在笔记本中导入:
import jupyternotify
ip = get_ipython()
ip.register_magics(jupyternotify.JupyterNotifyMagics)
.
并使用magic命令:
%%notify
import time
time.sleep(5)
.
并获得一个很好的通知:
git-page还展示了如何自动加载。
您是否使用iPython笔记本或终端的Ipython?如果您使用iPython笔记本,我建议使用 https://github.com/sjpfenninger/ipython-extensions (编写可用这里)
作为替代方案,我写了一个简单的模块/装饰函数来通知函数已完成(仅适用于Mac)
示例:
from ipynotifyer import notifyOnComplete as nf
@nf()
def divide_by_five():
return 5/5
@nf(timer=True)
def divide_by_ten():
return 5/10
.
当在不可见选项卡中输出时,最近的Iterm版本向通知中心发送通知。它们默认折叠到通知中心,但您可以将它们更改为在系统偏好设置中的通知首选项中留在屏幕上。
不隶属于 StackOverflow