jupyter notebook 遠端訪問配置

2021-10-04 03:03:31 字數 1813 閱讀 1400

首先是要安裝 anaconda 。

預設情況下,安裝好 anaconda 後開啟 jupyter notebook, 訪問本地localhost:8888即可。

但是如果要訪問另一台機器,比如遠端伺服器上的 notebook, 即預設是不支援 172.104.105.119:8888 這樣的訪問,需要額外配置。

設定 jupyter notebook 可遠端訪問的官方指南在這裡,在遠端伺服器上執行以下操作:

1.生成乙個 notebook 配置檔案

預設情況下,配置檔案~/.jupyter/jupyter_notebook_config.py並不存在,需要自行建立。使用下列命令生成配置檔案:

jupyter notebook --generate-config
如果是 root 使用者執行上面的命令,會發生乙個問題:

running as root it not recommended. use --allow-root to bypass.
提示資訊很明顯,root 使用者執行時需要加上--allow-root選項。

jupyter notebook --generate-config --allow-root
執行成功後,會出現下面的資訊:

writing default config to: /root/.jupyter/jupyter_notebook_config.py
2.生成密碼

從 jupyter notebook 5.0 版本開始,提供了乙個命令來設定密碼:jupyter notebook password,生成的密碼儲存在jupyter_notebook_config.json

$ jupyter notebook password

enter password: ****

verify password: ****

除了使用提供的命令,也可以通過手動安裝,我是使用的手動安裝,因為jupyter notebook password出來一堆內容,沒耐心看。開啟 ipython 執行下面內容:

ipython

in [1]: from notebook.auth import passwd

in [2]: passwd()

enter password:

verify password:

out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed這一串就是要在jupyter_notebook_config.py新增的密碼。

3.修改配置檔案

jupyter_notebook_config.py中找到下面的行,取消注釋並修改。

以上設定完以後就可以在伺服器上啟動 jupyter notebook,jupyter notebook, root 使用者使用jupyter notebook --allow-root。開啟 ip:指定的埠, 輸入密碼就可以訪問了。

需要注意的是不能在隱藏目錄 (以 . 開頭的目錄)下啟動 jupyter notebook, 否則無法正常訪問檔案。

遠端訪問jupyter notebook

ipython notebook是乙個基於瀏覽器的python資料分析工具,使用起來非常方便,具有極強的互動方式和富文字的展示效果。jupyter是它的公升級版,但是它預設只能在本地訪問,如果想把它安裝在伺服器上,然後在本地遠端訪問,則需要進行如下配置 1.登陸遠端伺服器 2.生成配置檔案 jupy...

Jupyter Notebook啟用conda環境

windows環境配置如下 1.開啟預設conda環境 root c users username 2.選擇要在jupyter notebook中啟用的env,並啟用 root style transfer d programdata miniconda3 envs style transfer r...

遠端訪問jupyter notebook

步驟如下 1.登入遠端伺服器 2.生成jupyter配置檔案 jupyter notebook generate config 3.手動生成密碼 開啟ipython,建立密碼的密文 in 1 from notebook.auth import passwd in 2 passwd enter pas...