The Jupyter Notebook interface is a Web-based application for authoring documents that combine live-code with narrative text, equations and visualizations.
Jupyter Notebook是基于网页的用于交互计算的应用程序。其可被应用于全过程计算:开
发、文档编写、运行代码和展示结果。——Jupyter Notebook官方介绍
JupyterNotebook本身有推荐的插件管理包,首先需要安装如下第三方库用于管理JupyterNotebook插件。
pip install jupyter_nbextensions_configurator
pip install jupyter_contrib_nbextensions
jupyter_nbextensions_configurator安装
jupyter_contrib_nbextensions安装
安装完成后,我们还需要执行如下命令来完成插件管理启用:
jupyter nbextensions_configurator enable --user
jupyter contrib nbextension install --user
This extension enables the CodeMirror feature to allow codefolding in code cells
The Variable Inspector extension collects all defined variables and display them in a floating window. The extension is also draggable, resizable, collapsable. 在右上角出现变量表。
Adds a scratchpad cell to Jupyter notebook.
打开一个便签,可以在当前内核上运行代码,但是不用再当前添加cell。使用 Shift + Enter 打开便签本,然后通过 Ctrl + B 将其关闭。
The toc2 extension enables to collect all running headers and display them in a floating window, as a sidebar or with a navigation menu. The extension is also draggable, resizable, collapsable, dockable and features automatic numerotation with unique links ids, and an optional toc cell.
打开后会在左侧出现目录。
Enable code autocompletion menu for every keypress in a code cell, instead of only enabling it with tab. 代码补全
Use kernel-specific code to reformat/prettify the contents of code cells # 代码补全功能
autopep8插件选中之后,使用时报错,报错信息如下图:
解决办法:(tf_2.5_py_3.7) C:\Users\hbwhx>conda install autopep8
Q:jupyter notebook running kernel in different env?
如何在jupyter notebook中在不同的环境中使用kenrel?
# solution
# This is a tricky part of ipython / Jupyter. The set of kernels available are independent of what your virtualenv is when you start jupyter Notebook. The trick is setting up the the ipykernel package in the environment you want to identify itself uniquely to jupyter. From docs on multiple ipykernels.
source activate ENVNAME
pip install ipykernel
python -m ipykernel install --user --name ENVNAME --display-name "Python (whatever you want to call it)"
This is a tricky part of ipython / Jupyter. The set of kernels available are independent of what your virtualenv is when you start jupyter Notebook. The trick is setting up the the ipykernel package in the environment you want to identify itself uniquely to jupyter. From docs on multiple ipykernels,
source activate ENVNAME
pip install ipykernel
python -m ipykernel install --user --name ENVNAME --display-name "Python (whatever you want to call it)"
# If you only want to have a single Python 3 kernel, from the conda environment, just use python -m ipykernel install --user and it will reset the default python to the one in the virtualenv.
实际操作
# 激活conda环境 tf_2.5_py_3.7
activate tf_2.5_py_3.7
# 安装 ipykernel 模块
pip install ipykernel
# 将指定的虚拟环境添加到kernel(ipython)
python -m ipykernel install --user --name tf_2.5_py_3.7 --display-name "tf_2.5_py_3.7"(在jupyter中显示的kernel名称)
设置成功后,就能在 jupyter notebook 中看到自己的 kernel了。其他kernel 的添加也可以按照此法进行。