gpt4 book ai didi

python - 如何在不使用 ctrl-c 的情况下关闭 jupyter notebook 应用程序(服务器)?

转载 作者:行者123 更新时间:2023-11-28 19:53:10 27 4
gpt4 key购买 nike

我在 Mac 的后台使用 jupyter notebook 运行

>jupyter notebook &

因为它在后台运行我不能使用 ctrl-c杀死它。此外,似乎没有进程具有名称 jupyter在事件监视器中。

这个 github 问题表明无法从浏览器执行此操作:https://github.com/jupyter/notebook/issues/1530但是它说应该可以使用 jupyter notebook stop <portno> 从命令行执行但这似乎对我不起作用。

如何关闭 jupyter 服务器(理想情况下无需搜索 pid 然后调用 kill)?

最佳答案

从jupyter notebook 5.1.0版本开始,命令

jupyter notebook stop <port number>

应该关闭笔记本服务器。如果您不输入端口,则默认为 8888,因为这是默认值。要了解服务器当前在哪些端口上运行,您可以执行以下操作

jupyter notebook list

对于 jupyter notebook 5.0 版,如果它在您的终端后台运行,解决方案是按照@juanpa.arrivillaga 在评论中写道:

jobs

查看后台运行的作业如果只有一个而且是 jupyter notebook 那么

fg

会将它带回前台,此时您可以使用 ctrl-c 将其杀死。而如果后台有很多进程,比如jobs返回

[1] Running firefox &

[2] Running jupyter notebook &

[3] Running python calc.py &

然后 fg 2 将需要的进程带回前台,以便能够使用 ctrl-c 杀死它,或者一步完成 kill %2

关于python - 如何在不使用 ctrl-c 的情况下关闭 jupyter notebook 应用程序(服务器)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46328135/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com