How to close IPython Notebook properly?

前端 未结 14 1124
渐次进展
渐次进展 2020-12-04 06:34

How to close IPython Notebook properly?

Currently, I just close the browser tabs and then use Ctrl+C in the terminal.
Unfortunately, neither e

相关标签:
14条回答
  • 2020-12-04 07:22

    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]
    
    0 讨论(0)
  • 2020-12-04 07:26

    Step 1 - On shell just do control+z (control+c) Step 2 _ close the web browser

    0 讨论(0)
  • 2020-12-04 07:32

    If you run jupyter in the background like me:

    jupyter notebook &> /dev/null &
    

    Then to exit jupyter completely, instead of Ctl-C, make an alias command:

    echo 'alias quitjupyter="kill $(pgrep jupyter)"' >> ~/.bashrc
    

    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':

    echo 'alias qjup="kill $(pgrep jupyter)"' >> ~/.bashrc
    

    Restart your terminal. Kill all jupyter instances:

    qjup
    
    0 讨论(0)
  • 2020-12-04 07:32

    Try killing the pythonw process from the Task Manager (if Windows) if nothing else works.

    0 讨论(0)
  • 2020-12-04 07:34

    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.

    0 讨论(0)
  • 2020-12-04 07:36
    Linux (Ubuntu 14.04)
    

    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.

    0 讨论(0)
提交回复
热议问题