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!