无法阻止Jupyter笔记本电脑

时间:2018-06-18 20:59:05

标签: python jupyter-notebook

我在远程计算机上运行Jupyter Notebook,我有一个受密码保护的帐户。如果我跑:

jupyter-notebook list

我告诉一个jupyter笔记本正在localhost:p运行,其中p是端口。在我的情况下,p = 8890。这可以。但是,当我跑:

jupyter-notebook stop 8890

我收到以下错误:

Shutting down server on port 8890 ...
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 1571, in start
    super(NotebookApp, self).start()
  File "/usr/local/lib/python2.7/dist-packages/jupyter_core/application.py", line 255, in start
    self.subapp.start()
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 451, in start
    if not self.shutdown_server(server):
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 442, in shutdown_server
    return shutdown_server(server, log=self.log)
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 402, in shutdown_server
    HTTPClient().fetch(req)
  File "/usr/local/lib/python2.7/dist-packages/tornado/httpclient.py", line 102, in fetch
    self._async_client.fetch, request, **kwargs))
  File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 458, in run_sync
    return future_cell[0].result()
  File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 238, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
tornado.httpclient.HTTPError: HTTP 403: Forbidden

我知道我可以通过使用kill -9杀死相应的进程来停止笔记本,但这并不是我真正想要的解决方案。关于什么可能导致这个问题的任何想法?

编辑:根据@Ereli的要求,我报告netstat -apn | grep 8890的输出(很遗憾,我没有超级用户权限,因此缺少sudo部分)

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:8890          0.0.0.0:*               LISTEN      169484/python   
tcp6       0      0 ::1:8890                :::*                    LISTEN      169484/python   
tcp6       0      0 ::1:50356               ::1:8890                ESTABLISHED -               
tcp6       0      0 ::1:50350               ::1:8890                ESTABLISHED -               
tcp6       0      0 ::1:8890                ::1:50356               ESTABLISHED 169484/python   
tcp6       0      0 ::1:8890                ::1:50350               ESTABLISHED 169484/python   
unix  2      [ ACC ]     STREAM     LISTENING     188903661 -                   /tmp/.java_pid153259.tmp
unix  2      [ ACC ]     STREAM     LISTENING     188904811 -                   /tmp/.java_pid153255.tmp
unix  2      [ ACC ]     STREAM     LISTENING     188906806 -                   /tmp/.java_pid153264.tmp
unix  2      [ ACC ]     STREAM     LISTENING     188904830 -                   /tmp/.java_pid153261.tmp
unix  2      [ ]         STREAM     CONNECTED     188902981 -                   
unix  2      [ ]         STREAM     CONNECTED     188906810 -                   
unix  2      [ ]         STREAM     CONNECTED     188904833 -  

1 个答案:

答案 0 :(得分:2)

尝试结合pkillps aux|grep processName的{​​{1}}。

kill

应该做的工作。 如果它不起作用,请使用

pkill jupyter

如果您想要限制只使用自己的进程,请尝试使用pkill -9 jupyter 标记。

-u

如果需要,可以杀死 pkill -u `id -u` jupyter ,因为它可能是文件。运行

这个issue似乎对jupyterhub团队开放,所以我认为它还没有修复。