jupyter notebook 遠程訪問

  1. 啓動 conda 環境, 輸入命令啓動 jupyterhtml

    jupyter notebook
    複製代碼

    在本地瀏覽器打開正常python

  2. 遠程訪問須要修改配置文件linux

    • 輸入命令瀏覽器

      jupyter notebook --generate-config
      複製代碼

      執行成功後,出現如下信息加密

      Writing default config to: /root/.jupyter/jupyter_notebook_config.py
      複製代碼

      會在/root/.jupyter/下面生成一個 jupyter_notebook_config.py 文件,用於jupyter的相關配置url

    • 生成密碼spa

      打開 ipython 執行如下內容.net

      In [1]: from notebook.auth import passwd
        In [2]: passwd()
        Enter password:
        Verify password:
        Out[2]: 'sha1:**************************************************'
      複製代碼

      sha1:************************************************** 這一串就是要在 jupyter_notebook_config.py 添加的密碼。code

    • 修改配置文件,添加密碼htm

      jupyter_notebook_config.py 文件中找到下面這行,修改並取消註釋。而後修改其餘兩行

      c.NotebookApp.password = u'sha:ce...剛纔複製的祕鑰'
        c.NotebookApp.ip = '*'
        c.NotebookApp.open_browser = False
      複製代碼
    • 啓動 jupyter, 瀏覽器輸入密碼就能夠訪問了。

  3. jupyter 不能用 root 啓動

    修改 jupyter_notebook_config.py 文件, 找到下面這行

    #c.NotebookApp.allow_root = False
    複製代碼

    取消註釋,改成 True 就能夠了。

    c.NotebookApp.allow_root = True
    複製代碼
  4. 其餘配置

    c.NotebookApp.ip = 'localhost'
     c.NotebookApp.open_browser = True(True:啓動時自動打開瀏覽器,False:需手動打開瀏覽器訪問http://localhost:8888/tree)
     c.NotebookApp.port = 8888(端口設置)
    複製代碼

參考:

  1. 設置 jupyter notebook 可遠程訪問
  2. linux端安裝Anaconda,方便遠端訪問jupyter
  3. 官方文檔
相關文章
相關標籤/搜索