[python] python環境設定 (安裝、設定環境變數、jupyter notebook)

Visits: 10

本文紀錄 python 的安裝,以及好用的工具 jupyter notebook 的安裝、設定與外觀設定。

python 環境設定

安裝好 python 後,需要讓windows的命令列可以執行pythonpip install 語法,就需要新增系統的環境變數,方法如下

  • 在系統變數的 Path 底下新增python.exe的執行路徑 (C:\Users\User\AppData\Local\Programs\Python\Python36-32)
  • 在系統變數的 Path 底下新增pip.exe的執行路徑(C:\Users\User\AppData\Local\Programs\Python\Python36-32\Scripts)

如圖所示
file

jupyter notebook 環境設定

安裝與設定

  1. 在 cmd 裡面,執行 pip install jupyter
  2. 安裝 jupyter 後,輸入jupyter notebook --generate-config後,到c:\users\users_name\.jupyter\jupyter_notebook_config.py打開,找到The directory to use for notebooks and kernels.,設定預設路徑,並且把註解去掉即可
  3. 若要在venv底下啟動jupyter notebook,先在venv底下執行ipython kernel install --user --name=.venv,接下來開啟jupyter notebook,指定新開的notebook kernel為.venv,即可
    file

外觀調整

這邊紀錄如何將 jupyter notebook 更換主題(參考文章)

  1. 先安裝 jupyter themes:pip install jupyterthemes

  2. 接下來輸入 !jt -l 看看有什麼可用的主題
    file

  3. 我慣用的是 onedork ,那就使用 !jt -t onedork 指令來變更主題。執行完畢後重開 jupyter notebook ,發現變更主題已成功。
    file

  4. 若想要還原,則使用 !jt -r 指令即可

其他功能

安裝 jupyter_contrib_nbextensions ,可以安裝更多的功能在 jupyter notebook 上,例如不用按 TAB 就能自動完成、 Codefolding …等功能(參考文章)

  1. 先在 cmd 安裝 pip install jupyter_contrib_nbextensions
  2. 接著安裝 pip install jupyter_nbextensions_configurator ,然後安裝圖形化介面後 jupyter nbextensions_configurator enable --user,最後安裝套件腳本 jupyter contrib nbextension install --user
  3. 啟動 jupyter notebook ,安裝自動完成的腳本 Hinterland
    file

About the Author

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

You may also like these