遠程使用服務器的jupyter notebook
1、在服務器端設置安裝jupyter,並配置
1、安裝jupyter, 使用如下的命令直接安裝
conda install jupyter
2、生成config文件
jupyter notebook --generate-config
3、生成密碼
#進入python
#然後輸入如下的命令
from notebook.auth import passwd
passwd()
#然後輸入兩次密碼,就會得到sha1
#輸入兩次密碼
#Enter password:
#Verify password:
#然後出現
#'sha1:xxxxxxxxxxxxxxxxx'
然後將帶引號的’sha1:xxxxxxxx’複製下來
4、修改之前生成的config文件
首先進入config文件
vim ~/.jupyter/jupyter_notebook_config.py
然後進行如下修改(直接粘貼):
c.NotebookApp.ip='*' #表示偵聽所有的ip
c.NotebookApp.password = u'sha:xxxxxx'#剛才複製的
c.NotebookApp.open_browser = False
c.NotebookApp.port =8123 #隨便指定一個
修改xshell
文件-打開-選擇服務器-右擊屬性-隧道:
點擊添加,然後在目標端口處填入上邊config中的8123端口,偵聽端口隨便填,例如填寫8123(本地打開時使用)
點擊確定,完成設置
服務器端打開jupyter
nohup jupyter notebook --no-browser --port=8123 &
然後在本地的瀏覽器中寫入
127.0.0.1:8123
輸入密碼就可以鏈接遠程的jupyter
jupyter使用conda環境
安裝ipythonkernel
conda install ipykernel
首先激活對應的conda環境
source activate 環境名稱
將環境寫入notebook的kernel中
python -m ipykernel install --user --name 環境名稱 --display-name "Python (環境名稱)"
然後運行,就可以在jupyter中看到對用的環境
jupyter notebook