8

我有两台机器通过局域网连接。其他系统的 IP 地址是 192.1xx.xx 我想在我的机器上运行 jupyter ipython 查询,它可以在他的机器上运行。在 ipython notebook 的开头,有一个黑屏,其中包含:

[I 11:12:52.802 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/

我可以将其更改为我指定的位置吗?

4

4 回答 4

13

您可以指定希望 Jupyter 运行的端口,取消注释/编辑以下行~/.jupyter/jupyter_notebook_config.py

#c.NotebookApp.port = 8888

如果您没有jupyter_notebook_config.py尝试运行jupyter notebook --generate-config. 有关Jupyter 配置的更多详细信息,请参阅此内容。

如果您在远程机器上访问 Jupyter,您也可以尝试让 Jupyter 在其默认端口上运行,并在您想要的端口上建立到本地机器的 SSH 隧道,例如:

ssh -fNL <new port>:localhost:8888 <your ssh config>
于 2016-11-05T09:30:33.047 回答
9

运行 Anaconda Prompt,生成配置文件,如果你没有它并编辑配置文件并使用你的 IP 地址“192.1xx.xx”更改 c.NotebookApp.ip

在 Anaconda 提示:如果文件不存在,则生成一个配置文件:

    jupyter notebook --generate-config

输出:

    (base) C:\Users\youruser>jupyter notebook --generate-config
    Writing default config to: C:\Users\youruser\.jupyter\jupyter_notebook_config.py
    (base) C:\Users\youruser>

切换到 jupyter 目录:

    cd .jupyter

修改配置文件:

    ## The IP address the notebook server will listen on.
    #c.NotebookApp.ip = 'localhost'

至:

    ## The IP address the notebook server will listen on.
    c.NotebookApp.ip = '192.1xx.x.x'
于 2018-08-28T15:31:18.687 回答
7

首先,您需要通过键入以下内容生成配置文件:

$> jupyter notebook --generate-config
Writing default config to: /{home-directory}/.jupyter/jupyter_notebook_config.py

接下来,您需要编辑该配置以更改端口号:

vi /{home-directory}/.jupyter/jupyter_notebook_config.py

查找以下行(默认情况下已注释掉)并在该行中进行注释并更改端口号:

(default configuration)
## The port the notebook server will listen on.
# c.NotebookApp.port = 8888

(comment removed, port changed)
## The port the notebook server will listen on.
c.NotebookApp.port = 9999
于 2017-06-20T16:09:38.317 回答
0

在 Mac 上,我必须使用我的机器名称而不是localhost.

为此,请打开终端并运行:

hostname

所以在浏览器中,而不是localhost:8888/...我输入mac-mini.home:8888/...(其中 ... 代表 url 的其余部分)。

我想找出在 Jupyter 配置中可以覆盖的位置,因为它不直观,IMO。

于 2021-11-04T07:12:15.630 回答