建議安裝anaconda,自帶python 和 jupyter lab
如果你已經在使用anaconda,並且也創建了虛擬環境,那么下面命令應當conda activate xxx 到在你的虛擬環境。
生成配置
jupyter lab --generate-config
默認的配置文件放在 "C:\Users\Administrator\.jupyter\jupyter_lab_config.py"
修改配置
c.ServerApp.allow_remote_access = True #設置允許遠程訪問 c.ServerApp.local_hostnames = ['192.168.1.xxx'] #設置主機名 c.ServerApp.root_dir = 'E:\\' #設置啟動后的jupyterlab的筆記文件根目錄 c.ServerApp.token = 'ddf3b439292e0f0027e36fafa3f70df04bf79c98936cb7d4' # 設置token 方便vscode配置jupyter
外部訪問
外部瀏覽器訪問 : http://192.168.1.xxx:8888/lab?token=ddf3b439292e0f0027e36fafa3f70df04bf79c98936cb7d4
vscode配置
Ctrl+shift+P 打開命令輸入框
Jupyter: 創建新的空白jupyter 筆記本
Jupyter: 指定本地或着遠程Jupyter服務器的連接--現有--填入 http://192.168.1.xxx:8888/lab?token=ddf3b439292e0f0027e36fafa3f70df04bf79c98936cb7d4 然后右下角會提示重啟vscode,重啟后,就可以創建一個筆記本用了
啟動和停止jupyterlab
啟動
- cmd窗口 jupyter lab
- conda navagator 點擊 jupyter lab 的 Lunch按鈕
停止
- cmd窗口 jupyter-lab stop 8888
注意事項
要想讓修改后的配置文件正確加載,必須正確關閉jupyter lab,
正確關閉jupyter lab的方法: 瀏覽器網頁端---文件---shutdown
所有的配置文件鍵值對,必須靠左定格寫