遠(yuǎn)程訪問JupyterLab服務(wù)器

1、遠(yuǎn)程訪問JupyterLab需要關(guān)鍵的兩步:

  • 安裝jupyterlab : pip install jupyterlab
  • 配置文件jupyter_notebook_config.py的配置

2、如何配置jupyter_notebook_config.py

2.1 創(chuàng)建配置文件

[jpnb@centos-7 ~]$ jupyter notebook --generate-config
Writing default config to: /home/jpnb/.jupyter/jupyter_notebook_config.py

其實(shí),直接在~/下,手動(dòng)創(chuàng)建隱藏文件夾.jupyter,并在其中創(chuàng)建配置文件jupyter_notebook_config.py,是一樣的。

??如果服務(wù)器端有兩個(gè)jupyterlab,則需要兩個(gè)不同的配置文件,那么在.jupyter再創(chuàng)建一個(gè)不同的配置文件即可,例如jupyter_notebook_config_2.py,只不過在啟動(dòng)jupyterlab時(shí)候,需要如下命令:

jupyter notebook --config jupyter_notebook_config_2.py

jupyter_notebook_config.py是默認(rèn)的配置文件,所以其對(duì)應(yīng)的jupyter在啟動(dòng)時(shí)候,直接使用如下命令即可

jupyter notebook

2.2 修改配置文件

1)創(chuàng)建一個(gè)訪問密碼,后面需要、通過網(wǎng)頁登陸時(shí)也需要

[jpnb@centos-7 ~]$ jupyter notebook password
Enter password: ****
Verify password: ****
[NotebookPasswordApp] Wrote hashed password to /home/jpnb/.jupyter/jupyter_notebook_config.json

2)獲取hash密碼
IPython中運(yùn)行

In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

3)修改配置文件

c.NotebookApp.password=u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
c.NotebookApp.port = 9999

其中,hash密碼就是上面生成的;端口號(hào)自由設(shè)置,不沖突即可

c.NotebookApp.allow_remote_access = True
c.NotebookApp.ip='*'
c.NotebookApp.open_browser = False

注意:u'sha1:...開頭的 u 不可省略

3、運(yùn)行

3.1 服務(wù)端啟動(dòng)

方式一:使用默認(rèn)的配置文件

[jpnb@centos-7 ~]$ jupyter notebook 

方式二:使用指定的配置文件

[jpnb@centos-7 ~]$ jupyter notebook --config jupyter_notebook_config_2.py

方式三:服務(wù)端掛起,這種情況能保證,即使服務(wù)端的終端關(guān)閉,jupyter也不會(huì)斷掉

[jpnb@centos-7 ~]$ nohup jupyter notebook &

3.2 客戶端使用

我們?cè)诘刂窓谥休斎脒h(yuǎn)程服務(wù)器的IP和端口號(hào):“http://192.168.31.176:9999/

輸入設(shè)置的密碼后,

OK!

參考文獻(xiàn)

如何設(shè)置遠(yuǎn)程訪問的Jupyter Notebook服務(wù)器-04(服務(wù)器篇)

如何用一臺(tái)服務(wù)器給多個(gè) Jupyter 用戶提供服務(wù)

?著作權(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)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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

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