zoukankan      html  css  js  c++  java
  • python 使用jupyter notebook

    在windows上通过浏览器远程连接Linux服务器的jupyter

    一、Linux服务器端配置
    1.启动ipython
    ipython

    2.创建远程连接密码,ipython下输入
    from notebook.auth import passwd
    passwd()
    输入两次密码,将得到一个字符串,比如'sha1:d6bd2dc6a8f6:79a1d0c95aff16bb4cc95fea6e2846fa9d6a654c'该终端不要关掉,复制该字符串,后面会用到;

    3.生成jupyter的配置文件,linux shell下输入
    jupyter notebook --generate-config
    将会在root目录下生成一个隐藏文件夹.jupyter,该文件夹中有一个jupyter的配置文件;

    4.打开配置文件
    vim /root/.jupyter/jupyter_notebook_config.py

    复制以下内容粘贴到配置文件中
    c.NotebookApp.ip = '*'
    c.NotebookApp.password=u'sha1:d6bd2dc6a8f6:79a1d0c95aff16bb4cc95fea6e2846fa9d6a654c'
    c.NotebookApp.port = 9001
    c.InteractiveShellApp.matplotlib = 'inline'

    5.设置jupyter notebook在后台不间断运行,且配置成错误信息输出到屏幕(可选),linux shell下输入
    nohup jupyter notebook >/dev/null 2>&1 &

    6、打开jupyter
    命令行输入:jupyter notebook

    二、windows客户端配置
    (1)需要安装一个windows远程ssh登录Linux的工具,可以是Xshell或SecureCRT,这两个工具的安装简单,如果遇到问题请自行百度;

    (2)Xshell或SecureCRT第一次启动需要新建连接,一般输入服务器IP地址、用户名、密码即可,这里不细述;

    (3)如果安装了Xshell,在Xshell的菜单栏,点击文件-属性-SSH-隧道-添加,侦听端口输入9001,目标主机设为服务器的IP地址,目标端口设为9001,“说明”中填入jupyter,确定。如果安装了SecureCRT,点击Options-Session Options-Port Forwarding-Add,name中填入jupyter,第一个port填入9001,勾选“Destination host is different from the SSH server”,填入服务器的IP地址,port填入9001,点两次OK;

    (4)在第(2)步成功远程登录命令行窗口中输入 $ jupyter notebook --allow-root;

    (5)打开本地windows的浏览器,地址栏输入localhost:9001/tree,回车,输入Linux服务器端配置时第(2)步设置的密码,回车,jupyter界面就出来了。

    错误解决:

    如果浏览器连接错误,可能是port设置错了,注意查看运行了 $ jupyter notebook的窗口中的内容,如果最下面几行是这样的:

    [I 22:24:20.259 NotebookApp] The port 9001 is already in use, trying another port.
    [I 22:24:20.264 NotebookApp] Serving notebooks from local directory: /home/duqi/genderPredict_duqi
    [I 22:24:20.264 NotebookApp] 0 active kernels
    [I 22:24:20.264 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:9002/
    [I 22:24:20.264 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    [W 22:24:20.265 NotebookApp] No web browser found: could not locate runnable browser.

    注意到第一行说明9001端口被使用了,第四行提示Jupyter Notebook在9002端口运行,这样的话就需要更改第(3)步中的本机端口设置为9002,然后在浏览器中也是输入9002

  • 相关阅读:
    Java RunTime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. ......
    UVA 1597 Searching the Web
    UVA 1596 Bug Hunt
    UVA 230 Borrowers
    UVA 221 Urban Elevations
    UVA 814 The Letter Carrier's Rounds
    UVA 207 PGA Tour Prize Money
    UVA 1592 Database
    UVA 540 Team Queue
    UVA 12096 The SetStack Computer
  • 原文地址:https://www.cnblogs.com/xl717/p/12154775.html
Copyright © 2011-2022 走看看