使用当前正在运行的进程连接到正在运行的Jupyter内核 [英] Connecting to a running Jupyter kernel with a currently running process

查看:338
本文介绍了使用当前正在运行的进程连接到正在运行的Jupyter内核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

整个周末,我在Jupyter笔记本中运行了一些长时间的进程,但是浏览器窗口有时关闭了.根据答案,该过程不应该被取消,但是无论我得到什么输出都会丢失.没关系,因为我只需要访问流程中的结果对象.我的目标是连接到控制台中正在运行的内核,然后从那里开始工作.根据 Jupyter的文档,我应该能够使用

Over the weekend I had some long processes running in a Jupyter notebook, but the browser window was closed at some point. According to this answer, the process shouldn't have been canceled, but whatever output I would have gotten would be lost. This is okay, as I only need access to the resulting objects from the process. My goal is to connect to the running kernel in the console, and work from there. According to Jupyter's documentation, I should be able to do this with

jupyter console --existing

但是运行此命令并悬挂一分钟后,我得到以下信息

But after running this and hanging for a minute I get the following

Traceback (most recent call last):
  File "/anaconda/envs/py35/lib/python3.5/site-packages/jupyter_console/ptshell.py", line 323, in init_kernel_info
    reply = self.client.get_shell_msg(timeout=1)
  File "/anaconda/envs/py35/lib/python3.5/site-packages/jupyter_client/client.py", line 77, in get_shell_msg
    return self.shell_channel.get_msg(*args, **kwargs)
  File "/anaconda/envs/py35/lib/python3.5/site-packages/jupyter_client/blocking/channels.py", line 57, in get_msg
    raise Empty
queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/anaconda/envs/py35/bin/jupyter-console", line 11, in <module>
    sys.exit(main())
  File "/anaconda/envs/py35/lib/python3.5/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/anaconda/envs/py35/lib/python3.5/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-116>", line 2, in initialize
  File "/anaconda/envs/py35/lib/python3.5/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/anaconda/envs/py35/lib/python3.5/site-packages/jupyter_console/app.py", line 141, in initialize
    self.init_shell()
  File "/anaconda/envs/py35/lib/python3.5/site-packages/jupyter_console/app.py", line 114, in init_shell
    client=self.kernel_client,
  File "/anaconda/envs/py35/lib/python3.5/site-packages/traitlets/config/configurable.py", line 412, in instance
    inst = cls(*args, **kwargs)
  File "/anaconda/envs/py35/lib/python3.5/site-packages/jupyter_console/ptshell.py", line 272, in __init__
    self.init_kernel_info()
  File "/anaconda/envs/py35/lib/python3.5/site-packages/jupyter_console/ptshell.py", line 326, in init_kernel_info
    raise RuntimeError("Kernel didn't respond to kernel_info_request")
RuntimeError: Kernel didn't respond to kernel_info_request

是因为长时间运行的进程仍在内核上运行还是发生了其他问题?所述过程完成后,是否可以使用上述命令按预期连接?

Is this occurring because my long-running process is still running on the kernel, or could there be an other issue? Should I be able to connect as expected using the above command when said process is complete?

推荐答案

解决方案* drumroll *:

The solution *drumroll*:

我只需要运行

jupyter console --existing 

与我运行的目录相同

jupyter notebook

这篇关于使用当前正在运行的进程连接到正在运行的Jupyter内核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆