1. Anaconda下安装Jupyter Notebook (Windows10)
pip install jupyter
2. 运行Jupyter
jupyter notebook
选择默认浏览器Chrome,此时弹出Jupyter页面但显示为空白
解决办法:
jupyter notebook --generate-config
然后打开 C:/user/.jupyter/jupyter_notebook_config.py 并添加如下代码
import webbrowser
webbrowser.register('chrome', None, webbrowser.GenericBrowser(u'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'))
c.NotebookApp.browser = 'chrome'
之后仍未奏效。在清理浏览器缓存后,页面可以正常显示。
3. 在 Notebooks 中使用 R,Julia 和JavaScript
- R: https://discuss.analyticsvidhya.com/t/how-to-run-r-on-jupyter-ipython-notebooks/551
- Julia: https://discuss.analyticsvidhya.com/t/how-to-run-r-on-jupyter-ipython-notebooks/5512
- JavaScript: https://github.com/n-riesco/ijavascript
4. 插件
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
安装后会出现Nbextensions选项卡
- Hinterland (Nbextensions选项卡中勾选)
- Snippets ((Nbextensions选项卡中勾选)
- Code prettify
- Printview
- Scratchpad
- Table of Contents
- JupyterLab: http://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html
- Matplotlib: http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-4-Matplotlib.ipynb
- RISE (“Live” Reveal.js Jupyter/IPython Slideshow Extension): https://github.com/damianavila/RISE
- Qgrid (可以像操作Excel里的筛选功能一样,方便的处理数据。)
pip install qgrid
jupyter nbextension enable --py --sys-prefix qgrid
# only required if you have not enabled the ipywidgets nbextension yet
jupyter nbextension enable --py --sys-prefix widgetsnbextension
- Jupyter Themes: https://github.com/dunovank/jupyter-themes
# install jupyterthemes
pip install jupyterthemes
# upgrade to latest version
pip install --upgrade jupyterthemes
# 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
5. 开始使用
- 命令行可直接使用shell命令(如 !pwd)
- Shift + Enter 可直接执行代码块