1. 程式人生 > >jupyter notebook實現遠端訪問

jupyter notebook實現遠端訪問

1、生成配置檔案

(windows在cmd下|linux在終端),輸入jupyter notebook --generate-config回車,會生成一個jupyter_notebook_config.py的配置檔案,這個檔案在使用者目錄下~/.jupyter/jupyter_notebook_config.py

2、生成密碼

開啟ipython(win系統下如果配置過環境變數的,可直接在cmd輸入ipython),

In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:                                 --輸入你的密碼(不要奇怪是密文看不見)
Verify password:                                --確認密碼
Out[2]: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'          --這是一串祕鑰,請複製

3、修改配置檔案

把第一步生成的配置檔案用記事本開啟,按照如下修改

c.NotebookApp.ip='*'              ---任意IP訪問
c.NotebookApp.password = xxx ---剛才複製的那個密文
c.NotebookApp.open_browser = False ---是否自動開啟瀏覽器
c.NotebookApp.port =8888           --隨便指定一個埠

4、重啟jupyter

注意:

如果無法訪問可能是防火牆的問題,如果可以訪問,但是無法執行程式碼,可能是配置檔案錯了