2017年11月1日 星期三

Anaconda 安裝啟動 IPython notebook 的問題(2) --- 修改Anaconda中的Jupyter Notebook 預設工作路徑

安裝 Anaconda 後,開啟 Jupyter notebook 其預設路徑都是在使用者帳號下,如果要變更開啟的預設路徑可以怎麼做呢?
以下有幾個方式供大家參考:
方法 1:
開啟命令提示字元( Command Line)畫面輸入以下指令並執行,Jupyter 會將設定檔 jupyter_notebook_config.py 產生,並顯示該設定檔的路徑以供查詢修改,設定檔若移除,則個人化設定將還原。
jupyter notebook --generate-config

執行後產生 jupyter_notebook_config.py。

開啟 jupyter_notebook_config.py 找到以下行進行修改
#c.NotebookApp.notebook_dir

進行以下修改:
1. 移除 " # "。
2. 填入指定的開起 jupyter notebook 的路徑,存檔。

開啟 Command Line,輸入 jupyter notebook 或 ipython notebook,這樣就可以在指定的路徑下開啟  jupyter notebook 。
方法 2:
在 Jupyter Notebook 上按滑鼠右鍵、內容。

修改開啟位置。

方法 3:
到 Anaconda 安裝路徑下 C:\ProgramData\Anaconda2\etc\jupyter 修改 jupyter_notebook_config.json 內容。

添加 "notebook_dir":"C:\\python" 。

PS:若 "C:\\python" 資料不存在,會造成開啟 Jupyter Notebook 有閃退的現象。

參考資料: