在现有的笔记本电脑上打开ipython笔记本 [英] Open ipython notebook on existing notebook server

查看:440
本文介绍了在现有的笔记本电脑上打开ipython笔记本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种在现有笔记本服务器上打开ipynb文件的方法。

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

我有一个笔记本文件 /home/myname/work_dir/test.ipynb
我需要一个脚本在笔记本上打开这个文件:

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!

我知道我可以通过以下命令在新的笔记本服务器上打开这个ipynb:

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.

在这种情况下,由于我知道执行笔记本的目录,我可以打开 test.ipynb 直接指定其相对路径:

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

所以我的问题是:


  • 是否有与上面提到的 ipynb_open 相对应的命令?

  • 有没有办法收集有关运行笔记本电脑服务器的信息?

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

推荐答案

打个招呼 nbopen ,就是这样!

https://github.com/takluyver/nbopen

运行笔记本服务器将JSON文件写入磁盘及其信息;有一个Python函数 notebook.notebookapp.list_running_servers()迭代正在运行的服务器,这就是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还包括桌面集成,因此您可以双击.ipynb文件将其打开。但是如果您愿意,可以在没有桌面集成的情况下安装 nbopen 命令。

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.

这篇关于在现有的笔记本电脑上打开ipython笔记本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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