1. 程式人生 > WINDOWS開發 >Windows10遠端訪問Ubuntu伺服器上的Jupyter Notebook解決辦法

Windows10遠端訪問Ubuntu伺服器上的Jupyter Notebook解決辦法

概要:

  可能有的同學在使用Python的時候喜歡使用.py檔案,而有的同學喜歡使用Jupyter Notebook做開發,但是苦於不會使用遠端伺服器的Jupyter Notebook而放棄,而這篇文章將教會你怎樣遠端訪問Jupyter Notebook。

官方地址:官方地址

遠訪配置:

  • 建立Jupyter Notebook配置檔案
$ jupyter notebook --generate-config
  • 設定Jupyter Notebook遠訪密碼
$ jupyter notebook password
Enter password: **** Verify password: **** [NotebookPasswordApp] Wrote hashed password to /Users/you/.jupyter/jupyter_notebook_config.json
  • 準備hash密碼
$ python
In [1]: from notebook.auth import passwd In [2]: passwd() Enter password: Verify password: Out[2]: ‘sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed‘
  • 編輯Jupyter Notebook配置檔案jupyter_notebook_config.py
$ vi /home/username/.jupyter/jupyter_notebook_config.py

c.NotebookApp.ip = ‘*‘
# 配置之前生成的hash密碼
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 Notebook服務
$ jupyter notebook

  現在我們就可以通過瀏覽器訪問遠端伺服器的Jupyter Notebook:https://your.host.com:9999 (your.host.com是你的遠端伺服器的IP地址)。注意:我們也可以用啟動Jupyter Notebook服務時伺服器指定的埠對Jupyter Notebook進行訪問。