Open ipython notebook on existing notebook server

不羁的心 提交于 2019-12-06 10:14:16

问题


I'm seeking a way to open ipynb file on an existing notebook server.

There is a notebook server on my home directory started as follows:

/home/myname$ ipython notebook

And I have a notebook file /home/myname/work_dir/test.ipynb. I need a script to open this file on the notebook:

cd work_dir
ipynb_open test.ipynb  # No such command!

I know that I can open this ipynb on a new notebook server by the following command:

ipython notebook test.ipynb

But this command stands a new server, and I have to kill this server by hands.

In this case, since I know the directory where the notebook is executed, I can open test.ipynb by directly specifying its relative path:

open http://localhost:8888/node/work_dir/test.ipynb

But I want to resolve this address automatically.

Reading documents, I found an option --existing, but following command does not work.

ipython notebook --exsiting test.ipynb

So my questions are:

  • Is there a command corresponding to ipynb_open noted above?
  • Is there a way to gather information about running notebook servers?

回答1:


Say hello to nbopen, which does exactly this!

https://github.com/takluyver/nbopen

Running notebook servers write JSON files to disk with their information; there's a Python function notebook.notebookapp.list_running_servers() that iterates over the running servers, and this is what nbopen uses.

Nbopen also includes desktop integration so you can double-click on a .ipynb file to open it. But you can install the nbopen command without the desktop integration if you prefer.



来源:https://stackoverflow.com/questions/34689319/open-ipython-notebook-on-existing-notebook-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!