如何从其他计算机接受ipython的连接?

ene*_*ene 53 configuration ipython

我在Ubuntu 12.04上运行ipython 0.12.1.您可以使用笔记本界面在浏览器中运行它:

ipython notebook --pylab
Run Code Online (Sandbox Code Playgroud)

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

{
  "stdin_port": 54204, 
  "ip": "127.0.0.1", 
  "hb_port": 58090, 
  "key": "2a105dd9-26c5-40c6-901f-a72254d59876", 
  "shell_port": 52155, 
  "iopub_port": 42228
}
Run Code Online (Sandbox Code Playgroud)

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

min*_*nrk 113

如果您使用的是旧版笔记本,则以下内容仍然适用.对于新版本,请参阅下面的其他答案.


IPython文档的相关部分

Notebook服务器默认侦听localhost.如果您希望LAN上的所有计算机都可以看到它,只需指示它监听所有接口:

ipython notebook --ip='*'
Run Code Online (Sandbox Code Playgroud)

或者其他机器可见的特定IP:

ipython notebook --ip=192.168.0.123
Run Code Online (Sandbox Code Playgroud)

根据您的环境,在侦听外部接口时启用HTTPS和密码可能是个好主意.

如果你计划公开服务,那么创建一个IPython配置文件(例如ipython profile create nbserver)并相应地编辑配置也是一个好主意,所以你需要做的就是:

ipython notebook --profile nbserver
Run Code Online (Sandbox Code Playgroud)

加载所有ip/port/ssl /密码设置.


cen*_*enk 16

接受的答案/信息适用于旧版本.如何启用远程访问新的jupyter笔记本?我帮你了

首先,如果您还没有配置文件,请生成配置文件:

jupyter notebook --generate-config
Run Code Online (Sandbox Code Playgroud)

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

## The IP address the notebook server will listen on.
c.NotebookApp.ip = '0.0.0.0' # Any ip
Run Code Online (Sandbox Code Playgroud)

为了增加安全性,请键入python/IPython shell:

from notebook.auth import passwd; passwd()
Run Code Online (Sandbox Code Playgroud)

系统将要求您输入并确认密码字符串.复制字符串的内容,其格式应为: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 = '*'
Run Code Online (Sandbox Code Playgroud)

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