Run Jupyter notebook remotely


1. 安裝Anaconda

省略

2. 生成配置文件

$ jupyter notebook --generate-config

默認(rèn)配置文件的位置

Windows: C:\Users\USERNAME\.jupyter\jupyter_notebook_config.py
OS X: /Users/USERNAME/.jupyter/jupyter_notebook_config.py
Linux: /home/USERNAME/.jupyter/jupyter_notebook_config.py

3. 設(shè)置jupyter密碼

$ jupyter notebook password
Enter password:  ****
Verify password: ****
[NotebookPasswordApp] Wrote hashed password to /Users/you/.jupyter/jupyter_notebook_config.json

哈希密碼默認(rèn)在~/.jupyter/jupyter_notebook_config.json

4. 用SSL加密通訊

生成加密證書(shū)

$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mykey.key -out mycert.pem

編輯配置文件~/.jupyter/jupyter_notebook_config.py

# Set options for certfile, ip, password, and toggle off
# browser auto-opening
c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/mycert.pem'
c.NotebookApp.keyfile = u'/absolute/path/to/your/certificate/mykey.key'
# Set ip to '*' to bind on all interfaces (ips) for the public server
c.NotebookApp.ip = '*'
c.NotebookApp.password = u'sha1:bcd259ccf...<your hashed password here>'
c.NotebookApp.open_browser = False

# It is a good idea to set a known, fixed port for server access
c.NotebookApp.port = 9999

好像是由于jupyter的版本原因,啟動(dòng)會(huì)出一個(gè)ValueError: '' does not appear to be an IPv4 or IPv6 address這樣的錯(cuò),把c.NotebookApp.ip = '*'里面的*換成0.0.0.0 work for me (見(jiàn)參考2)

5. 后臺(tái)啟動(dòng)

$ nohup jupyter lab &

然后就可以本地通過(guò)瀏覽器打開(kāi)(要用https不是http),記得加你設(shè)置的端口號(hào)(e.g., https://server_address:9999


Rerefences

  1. Jupyter Notebook官方文檔:https://jupyter-notebook.readthedocs.io/en/stable/public_server.html
  2. StackOverflow:https://github.com/jupyter/notebook/issues/3946

版本信息

Linux版本

NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

Anaconda版本

     active environment : base
    active env location : /home/xiangjie/programs/anaconda3
            shell level : 1
       user config file : /home/xiangjie/.condarc
 populated config files : 
          conda version : 4.6.11
    conda-build version : 3.17.8
         python version : 3.7.3.final.0
       base environment : /home/xiangjie/programs/anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/xiangjie/programs/anaconda3/pkgs
                          /home/xiangjie/.conda/pkgs
       envs directories : /home/xiangjie/programs/anaconda3/envs
                          /home/xiangjie/.conda/envs
               platform : linux-64
             user-agent : conda/4.6.11 requests/2.21.0 CPython/3.7.3 Linux/3.10.0-862.11.6.el7.x86_64 centos/7.5.1804 glibc/2.17
                UID:GID : 1063:500
             netrc file : None
           offline mode : False
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 今天我們來(lái)入門Jupyter notebook這個(gè)東西,研究一下它的功能目錄:一、簡(jiǎn)介二、安裝與運(yùn)行三、Pytho...
    hwang_zhic閱讀 3,813評(píng)論 0 6
  • Introduction Jupyter Notebookis an open-source, interacti...
    ???木?燚??閱讀 543評(píng)論 0 0
  • 1,感恩 假期三天就這么過(guò)去了,感覺(jué)什么都沒(méi)做,計(jì)劃沒(méi)完成,但內(nèi)心很平安! 2、感恩 和女兒相處越來(lái)越開(kāi)心,從神的...
    茉莉越閱讀 349評(píng)論 0 1
  • 第五章 模型后處理 作者:Trent Hauck 譯者:飛龍 協(xié)議:CC BY-NC-SA 4.0 5.1 K-f...
    布客飛龍閱讀 2,094評(píng)論 0 8

友情鏈接更多精彩內(nèi)容