在更新Mac OS X 10.12.5后,發現當通過Anaconda打開JupyterNotebook時出現了以下錯誤,而且JupyterNotebook並沒有通過瀏覽器啟動
我們退出Anaconda,系統提示是否退出JupyterNotebook,這說明JupyterNotebook已經在8888端口上運行了
我們在瀏覽器地址欄輸入(http://localhost:8888)就可以跳轉到JupyterNotebook頁面,但此時我們會發現頁面要求我們輸入密碼
但這個密碼之前並沒有被設置過,嘗試失敗后頁面會提示密碼無效
我們點擊(enable a password)可以進入幫助頁面並得到以下解決方法
按說明創建一個系統配置文件文件,新建一個終端並輸入以下內容:
jupyter notebook --generate-config
系統提示未找到jupyter指令,這是因為我們的JupyterNotebook是通過Anaconda來執行的:
-bash: jupyter: command not found
所以我們要預先配置好Anaconda的環境變量,在終端輸入:
export PATH=~/anaconda/bin:$PATH
這時我們再次輸入以下內容,創建一個jupyter的系統配置文件(直接安裝的JupyterNotebook應該不會出現以上問題):
jupyter notebook --generate-config
系統提示以下內容,需要我們去選擇是否在該目錄下創建該配置文件:
Overwrite /Users/caiyutong/.jupyter/jupyter_notebook_config.py with default config? [y/N]
我們在終端鍵入“y”並回車確認創建該文件,系統提示以下內容:
Writing default config to: /Users/caiyutong/.jupyter/jupyter_notebook_config.py
系統配置文件創建成功后在終端輸入以下內容並進行密碼設置:
jupyter notebook password
輸入兩次密碼后完成設置,終端顯示以下內容:
Enter password:
Verify password:
[NotebookPasswordApp] Wrote hashed password to /Users/caiyutong/.jupyter/jupyter_notebook_config.json
完成設置后我們通過Anaconda進入JupyterNotbook,系統依然提示“不理解“open location”信息。 (-1708)”
但我們這事可以注意到,JupyterNotebook的運行端口變成了8889,我們復制該地址黏貼到瀏覽器地址欄
(http://localhost:8889/tree)注:請復制在終端上顯示的地址,運行后端口可能不是8889
我們會發現系統要求我們輸入密碼,我們輸入剛才在終端所設置的密碼后,便可以進入JupyterNotebook
參考資料1:https://jupyter-notebook.readthedocs.io/en/stable/public_server.html
(關於JupyterNotebook密碼設置)
參考資料2:https://www.168seo.cn/mac-os/23603.html
(關於JupyterNotebook報錯及不能通過瀏覽器打開)
參考資料3:https://stackoverflow.com/questions/44057601/ipython-notebook-will-not-start-on-command-line
(關於JupyterNotebook不能通過命令行開啟)
參考資料4:http://www.cnblogs.com/coolcold/p/6907787.html
(關於JupyterNotebook報錯及不能通過瀏覽器打開)