Configuration 如何接受来自其他计算机的ipython连接?

Configuration 如何接受来自其他计算机的ipython连接?,configuration,ipython,Configuration,Ipython,我在Ubuntu 12.04上运行ipython 0.12.1。您可以使用笔记本电脑界面在浏览器中运行它,方法是运行: ipython notebook --pylab 配置文件可以在~/.config/ipython/profile\u default/中找到。似乎每个内核的连接参数都放在~/.config/ipython/profile\u default/security/kernel-4e424cf4-ba44-441a-824c-c6bce727e585.json中。以下是此文件的内

我在Ubuntu 12.04上运行ipython 0.12.1。您可以使用笔记本电脑界面在浏览器中运行它,方法是运行:

ipython notebook --pylab
配置文件可以在
~/.config/ipython/profile\u default/
中找到。似乎每个内核的连接参数都放在
~/.config/ipython/profile\u default/security/kernel-4e424cf4-ba44-441a-824c-c6bce727e585.json
中。以下是此文件的内容(启动新内核时会创建新文件):


这是不言自明的,但我如何设置一个具有永久配置的服务器,以便我可以使用局域网中其他计算机的笔记本接口?

如果您使用的是旧版本的笔记本,以下内容仍然适用。有关新版本,请参见下面的其他答案


默认情况下,笔记本服务器在本地主机上侦听。如果希望LAN上的所有计算机都能看到它,只需指示它在所有接口上侦听即可:

ipython notebook --ip='*'
或其他机器可见的特定IP:

ipython notebook --ip=192.168.0.123
根据您的环境,在侦听外部接口时,可能最好使用

如果您计划大量公开服务,那么创建IPython配置文件(例如,
IPython配置文件create nbserver
)并相应地编辑配置也是一个好主意,因此您需要做的只是:

ipython notebook --profile nbserver
加载所有ip/端口/ssl/密码设置。

接受的答案/信息适用于旧版本。如何启用对新jupyter笔记本的远程访问?我把你掩护起来了 首先,如果尚未生成配置文件,请生成该文件:

jupyter notebook --generate-config
请注意此命令的输出,因为它将告诉您生成
jupyter\u notebook\u config.py
文件的位置。或者,如果您已经拥有它,它会询问您是否要用默认配置覆盖它。编辑以下行:

## The IP address the notebook server will listen on.
c.NotebookApp.ip = '0.0.0.0' # Any ip
为了增加安全性,请键入python/IPython shell:

from notebook.auth import passwd; passwd()
系统将要求您输入并确认密码字符串。复制字符串的内容,其格式应为:salt:hashed password。查找并编辑以下行:

## Hashed password to use for web authentication.
#  
#  To generate, type in a python/IPython shell:
#  
#    from notebook.auth import passwd; passwd()
#  
#  The string should be of the form type:salt:hashed-password.
c.NotebookApp.password = 'type:salt:the-hashed-password-you-have-generated'

## Forces users to use a password for the Notebook server. This is useful in a
#  multi user environment, for instance when everybody in the LAN can access each
#  other's machine through ssh.
#  
#  In such a case, server the notebook server on localhost is not secure since
#  any user can connect to the notebook server via ssh.
c.NotebookApp.password_required = True

## Set the Access-Control-Allow-Origin header
#  
#  Use '*' to allow any origin to access your server.
#  
#  Takes precedence over allow_origin_pat.
c.NotebookApp.allow_origin = '*'

(重新)启动你的jupyter笔记本,瞧

您想从LAN上的其他计算机使用笔记本,还是直接使用内核(例如,打开QtConsole共享现有笔记本的内核等)?答案是不同的。@minrk我想运行服务器,我可以从局域网中的另一台计算机上通过浏览器连接到该服务器,并具有笔记本界面,就像我在本地运行命令ipython notebook--pylab一样,但在这种情况下,我必须在局域网中写入另一台计算机的地址,例如,而不是在那种情况下,内核连接文件与您无关(它们是笔记本服务器与内核对话的方式)。回答即将到来…您可以使用
--NotebookApp.token='
(可能不安全):根据,我还需要
c.NotebookApp.allow_origin='*'
。@ijoseph感谢您的贡献,在回答中添加了allow_origin!
## Hashed password to use for web authentication.
#  
#  To generate, type in a python/IPython shell:
#  
#    from notebook.auth import passwd; passwd()
#  
#  The string should be of the form type:salt:hashed-password.
c.NotebookApp.password = 'type:salt:the-hashed-password-you-have-generated'

## Forces users to use a password for the Notebook server. This is useful in a
#  multi user environment, for instance when everybody in the LAN can access each
#  other's machine through ssh.
#  
#  In such a case, server the notebook server on localhost is not secure since
#  any user can connect to the notebook server via ssh.
c.NotebookApp.password_required = True

## Set the Access-Control-Allow-Origin header
#  
#  Use '*' to allow any origin to access your server.
#  
#  Takes precedence over allow_origin_pat.
c.NotebookApp.allow_origin = '*'