Hits: 4730
本文紀錄 python 的安裝,以及好用的工具 jupyter notebook 的安裝、設定與外觀設定。
python 環境設定
安裝好 python 後,需要讓windows的命令列可以執行python
與pip 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
)
如圖所示
jupyter notebook 環境設定
安裝與設定
- 在 cmd 裡面,執行
pip install jupyter
- 安裝 jupyter 後,輸入
jupyter notebook --generate-config
後,到c:\users\users_name\.jupyter\jupyter_notebook_config.py
打開,找到The directory to use for notebooks and kernels.
,設定預設路徑,並且把註解去掉即可 - 若要在venv底下啟動jupyter notebook,先在venv底下執行
ipython kernel install --user --name=.venv
,接下來開啟jupyter notebook,指定新開的notebook kernel為.venv,即可
外觀調整
這邊紀錄如何將 jupyter notebook 更換主題(參考文章)
-
先安裝 jupyter themes:
pip install jupyterthemes
-
接下來輸入
!jt -l
看看有什麼可用的主題
-
我慣用的是 onedork ,那就使用
!jt -t onedork
指令來變更主題。執行完畢後重開 jupyter notebook ,發現變更主題已成功。
-
若想要還原,則使用
!jt -r
指令即可
其他功能
安裝 jupyter_contrib_nbextensions ,可以安裝更多的功能在 jupyter notebook 上,例如不用按 TAB 就能自動完成、 Codefolding …等功能(參考文章)
- 先在 cmd 安裝
pip install jupyter_contrib_nbextensions
- 接著安裝
pip install jupyter_nbextensions_configurator
,然後安裝圖形化介面後jupyter nbextensions_configurator enable --user
,最後安裝套件腳本jupyter contrib nbextension install --user
- 啟動 jupyter notebook ,安裝自動完成的腳本
Hinterland
Comments