相關文章:
【1】Anaconda安裝超簡潔教程,瞬間學會!
【2】Anaconda下:ipython檔案的打開方式,Jupyter Notebook中運行.py檔案,快速打開ipython檔案的方法!
【3】jupyter notebook修改主題、字體、字號、代碼自動補全、變更作業目錄、添加目錄插件、解決工具列隱藏問題、修改默認瀏覽器
【4】jupyter notebook快速入門、以及常用快捷鍵使用
1.jupyter notebook 修改主題、字體字號等設定
github鏈接地址:https://codechina.csdn.net/mirrors/dunovank/jupyter-themes?utm_source=csdn_github_accelerator

這個畫圖比原版的好看多了吧!
安裝指令:
#通過anaconda安裝
conda install jupyterthemes
#通過pip安裝
pip install jupyterthemes
# upgrade to latest version
pip install --upgrade jupyterthemes
查看可用主題:
#通過命令jt -l 可查看主題串列,效果如下
C:\Users\dell>jt -l
Available Themes:
chesterish #暗色
grade3 #亮色
gruvboxd #暗色
gruvboxl #淡棕色
monokai #暗色 推薦
oceans16 #暗色 推薦 個人在使用
onedork #暗色 推薦
solarizedd #青色
solarizedl #淡粉色
效果如下:

檔案這里介紹了詳細的可用引數:
命令列用法
jt [-h] [-l] [-t THEME] [-f MONOFONT] [-fs MONOSIZE] [-nf NBFONT]
[-nfs NBFONTSIZE] [-tf TCFONT] [-tfs TCFONTSIZE] [-dfs DFFONTSIZE]
[-m MARGINS] [-cursw CURSORWIDTH] [-cursc CURSORCOLOR] [-vim]
[-cellw CELLWIDTH] [-lineh LINEHEIGHT] [-altp] [-altmd] [-altout]
[-P] [-T] [-N] [-r] [-dfonts]

后面還有如何使用的樣例,比如這樣修改oceans16主題的Code(python代碼)的字體與字號:
jt -t oceans16 -f fira -fs 13
其他可用引數還包括-cellw(占屏比或寬度) -ofs(輸出段的字號) -T(顯示工具列)等等,各位可以查閱檔案;這是我的設定
jt -t oceans16 -f fira -fs 14 -cellw 95% -ofs 11 -dfs 12 -T
# list available themes
# onedork | grade3 | oceans16 | chesterish | monokai | solarizedl | solarizedd
jt -l
# select theme...
jt -t chesterish
# restore default theme
# NOTE: Need to delete browser cache after running jt -r
# If this doesn't work, try starting a new notebook session.
jt -r
# toggle toolbar ON and notebook name ON
jt -t grade3 -T -N
# toggle kernel logo. kernel logo is in same container as name
# toggled with -N. That means that making the kernel logo visible is
# pointless without also making the name visible
jt -t grade3 -N -kl
# set code font to 'Roboto Mono' 12pt
# (see monospace font table below)
jt -t onedork -f roboto -fs 12
# set code font to Fira Mono, 11.5pt
# 3digit font-sizes get converted into float (115-->11.5)
# 2digit font-sizes > 25 get converted into float (85-->8.5)
jt -t solarizedd -f fira -fs 115
# set font/font-size of markdown (text cells) and notebook (interface)
# see sans-serif & serif font tables below
jt -t oceans16 -tf merriserif -tfs 10 -nf ptsans -nfs 13
# adjust cell width (% screen width) and line height
jt -t chesterish -cellw 90% -lineh 170
# or set the cell width in pixels by leaving off the '%' sign
jt -t solarizedl -cellw 860
# fix the container-margins on the intro page (defaults to 'auto')
jt -t monokai -m 200
# adjust cursor width (in px) and make cursor red
# options: b (blue), o (orange), r (red), p (purple), g (green), x (font color)
jt -t oceans16 -cursc r -cursw 5
# choose alternate prompt layout (narrower/no numbers)
jt -t grade3 -altp
# my two go-to styles
# dark
jt -t onedork -fs 95 -altp -tfs 11 -nfs 115 -cellw 88% -T
# light
jt -t grade3 -fs 95 -altp -tfs 11 -nfs 115 -cellw 88% -T
2.代碼補全的設定方法
使用conda或pip安裝jupyter_contrib_nbextensions和jupyter_nbextensions_configurator
conda install jupyter_contrib_nbextensions
conda install jupyter_nbextensions_configurator
安裝完成后重新打開jupyternotebook,在選單欄可以看到 NBextensions這個選項,在其中勾選上“Hinterland”即可打開自動補全

效果如下:

3.修改默認目錄
打開cmd,輸入命令
jupyter notebook --generate-config

在提示路徑下,找到jupyter_notebook_config.py檔案,打開進行編輯
## The directory to use for notebooks and kernels.
#c.NotebookApp.notebook_dir = ''

找到jupyter notebook的快捷方式,右鍵-屬性;洗掉"%USERPROFILE%/"重新啟動軟體,看到圖中,新作業目錄已經生效.


4.Jupyter Notebook 添加目錄插件
點開 Nbextensions 的選項,并勾選 Table of Contents

效果如下:

5.解決更改主題后工具列ToolBar隱藏問題
步驟一:命令列設定toolbar可見
C:\Users\Lenovo>jt -t oceans16 -N -T
6. Jupyter-notebook 修改默認瀏覽器和默認打開位置
在cmd里輸入
jupyter notebook --generate-config
到提示的路徑下找到jupyter_notebook_config.py
搜索' c.NotebookApp.notebook_dir '
## The directory to use for notebooks and kernels.
# c.NotebookApp.notebook_dir = ''
將本行的“#”去掉,并在后面的單引號中添加你想設定的目錄
搜索‘ c.NotebookApp.browser ’,在下面增加以下陳述句:
洗掉c.NotebookApp.notebook_dir 前面的“#”符號(#表示注釋的意思),然后修改為自己創建的目錄路徑,保存.py檔案,不同作業系統的電腦路徑不一樣,windows是雙斜杠(\),linux是反斜杠(/)
import webbrowser
webbrowser.register(
"Firefox", #自定義名字
None,
webbrowser.GenericBrowser(u"E:\\Program Files\\Firefox\\firefox.exe"))#指定程式所在位置
c.NotebookApp.browser = "Firefox"
重新進入軟體!!!
7. 設定快捷方式中的目標與起始位置
找到jupyter notebook的快捷方式,右鍵-屬性

默認目標欄和起始位置中會帶有環境變數的引數,刪掉掉% %包裹的變數,直接修改成如下圖,將下圖紅框的地方都替換成你自己的“notebook作業檔案夾”

這樣修改,以后再快捷方式啟動的jupyter notebook初始作業目錄也是你想設定的路徑,
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/278474.html
標籤:python
上一篇:深度神經網路結構可視化(Pytorch、Tensorflow、Keras、Caffe、MXNet、PaddlePaddle等主流框架)
