Currently, I just close the browser tabs and then use Ctrl+C in the terminal.
Unfortunately, neither exit() nor ticking Kill kernel upon exit does help (they do kill the kernel they but don’t exit the iPython).
There isn’t currently a better way to do it than Ctrl+C in the terminal.
We’re thinking about how to have an explicit shutdown, but there’s some tension between the notebook as a single-user application, where the user is free to stop it, and as a multi-user server, where only an admin should be able to stop it. We haven’t quite worked out how to handle the differences yet.
(For future readers, this is the situation with 0.12 released and 0.13 in development.)
Update December 2017
The IPython Notebook has become the Jupyter Notebook. A recent version has added a jupyter notebook stop shell command which will shut down a server running on that system. You can pass the port number at the command line if it’s not the default port 8888.
You can also use nbmanager, a desktop application which can show running servers and shut them down.
Finally, we are working on adding:
A config option to automatically shut down the server if you don’t use it for a specified time.
A button in the user interface to shut the server down. (We know it’s a bit crazy that it has taken this long. Changing UI is controversial.)
Restart your terminal. Kill all jupyter instances:
quitjupyter
Note: use double quotes inside of single quotes as shown above. The other way around will evaluate the expression before writing it to your .bashrc (you want to write the command itself not ‘kill 1430’ or whatever process number may be associated with a current jupyter instance). Of course you can use any alias you wish. I actually use ‘qjup’:
$ jupyter notebook stop Shutting down server on port 8888...
它也将端口号作为参数,您可以正常关闭jupyter笔记本。
例如:
jupyter notebook stop 8889Shutting down server on port 8889...
此外,要了解您当前的juypter实例正在运行,请检查以下命令:
shell> juypter notebook list Currently running servers:
http://localhost:8888/?token=ef12021898c435f865ec706d7c9af8607a7ba58bbee98632 ::/Users/username/jupyter-notebooks [/code]
First step is to save all open notebooks. And then think about shutting down your running Jupyter Notebook. You can use this simple command:
$ jupyter notebook stop
Shutting down server on port 8888 ...
Which also takes the port number as argument and you can shut down the jupyter notebook gracefully.
For eg:
jupyter notebook stop 8889
Shutting down server on port 8889 ...
Additionally to know your current juypter instance running, check below command:
shell> juypter notebook list
Currently running servers:
http://localhost:8888/?token=ef12021898c435f865ec706d7c9af8607a7ba58bbee98632 :: /Users/username/jupyter-notebooks [/code]
回答 4
这些命令对我有用:
jupyter notebook list # shows the running notebooks and their port-numbers# (for instance: 8080)
lsof -n -i4TCP:[port-number]# shows PID.
kill -9[PID]# kill the process.
As mentioned, try to kill ipython notebook processes properly by first going to the “running” tab in your ipynb/jupyter browser session, and then check open terminals on your console and shut down with ctrl-c. The latter should be avoided if possible.
If you run an ipython notebook list and continue to see running ipython servers at different ports, make note of which ports the existing notebooks are being served to. Then shut down your TCP ports:
fuser -k 'port#'/tcp
I’m not sure if there are other risks involved with doing this. If so, let me know.
回答 7
环境
我的操作系统是Ubuntu 16.04,jupyter是4.3.0。
方法
首先,我在浏览器的主页上注销了jupyter(注销按钮在右上角)
第二,输入Ctrl + C您的终端,它显示:
[I 15:59:48.407 NotebookApp]从本地目录中断服务笔记本:/ home / Username 0活动内核
Actually, I believe there’s a cleaner way than killing the process(es) using kill or task manager.
In the Jupyter Notebook Dashboard (the browser interface you see when you first launch ‘jupyter notebook’), browse to the location of notebook files you have closed in the browser, but whose kernels may still be running.
iPython Notebook files appear with a book icon, shown in green if it has a running kernel, or gray if the kernel is not running.
Just select the tick box next to the running file, then click on the Shutdown button that appears above it.
This will properly shut down the kernel associated with that specific notebook.
回答 9
在浏览器会话中,您也可以转到Kernel,然后单击Restart and Clear Output。
1.3.3 Close a notebook: kernel shut down
When a notebook is opened, its “computational engine” (called the kernel) is automatically started. Closing the
notebook browser tab, will not shut down the kernel, instead the kernel will keep running until is explicitly shut down.
To shut down a kernel, go to the associated notebook and click on menu File -> Close and Halt. Alternatively, the
Notebook Dashboard has a tab named Running that shows all the running notebooks (i.e. kernels) and allows shutting
them down (by clicking on a Shutdown button).
Summary: First close and halt the notebooks running.
1.3.2 Shut down the Jupyter Notebook App
Closing the browser (or the tab) will not close the Jupyter Notebook App. To completely shut it down you need to
close the associated terminal.
In more detail, the Jupyter Notebook App is a server that appears in your browser at a default address
(http://localhost:8888). Closing the browser will not shut down the server. You can reopen the previous address
and the Jupyter Notebook App will be redisplayed.
You can run many copies of the Jupyter Notebook App and they will show up at a similar address (only the number
after “:”, which is the port, will increment for each new copy). Since with a single Jupyter Notebook App you can
already open many notebooks, we do not recommend running multiple copies of Jupyter
Notebook App.
Summary: Second, quit the terminal from which you fired Jupyter.