我是靠谱客的博主 淡定帆布鞋,最近开发中收集的这篇文章主要介绍JupyterNotebook插件管理与安装JupyterNotebook插件管理与安装,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

JupyterNotebook插件管理与安装

1.JupyterNotebook简介

​ 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官方介绍

2.JupyterNotebook插件管理

​ JupyterNotebook本身有推荐的插件管理包,首先需要安装如下第三方库用于管理JupyterNotebook插件。

pip install jupyter_nbextensions_configurator
pip install jupyter_contrib_nbextensions

jupyter_nbextensions_configurator安装
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Dn1UVBm5-1639978848469)(C:UsershbwhxDesktop学习12_toolJupyterNotebookJupyterNotebook插件管理与安装.assetsimage-20211220103412139.png)]
jupyter_contrib_nbextensions安装
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-eX6b2b4v-1639978848471)(C:UsershbwhxDesktop学习12_toolJupyterNotebookJupyterNotebook插件管理与安装.assetsimage-20211220105450184.png)]

安装完成后,我们还需要执行如下命令来完成插件管理启用:

jupyter nbextensions_configurator enable --user
jupyter contrib nbextension install --user

3.JupyterNotebook常用插件

3.1 Codefolding

This extension enables the CodeMirror feature to allow codefolding in code cells

可以折叠代码块,当代码多的时候,保持代码整洁性。
在这里插入图片描述

3.2 Variable Inspector

The Variable Inspector extension collects all defined variables and display them in a floating window. The extension is also draggable, resizable, collapsable. 在右上角出现变量表。
在这里插入图片描述

3.3 Scratchpad

Adds a scratchpad cell to Jupyter notebook.

打开一个便签,可以在当前内核上运行代码,但是不用再当前添加cell。使用 Shift + Enter 打开便签本,然后通过 Ctrl + B 将其关闭。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-p93M8gsv-1639978848473)(C:UsershbwhxDesktop学习12_toolJupyterNotebookJupyterNotebook插件管理与安装.assetsimage-20211220112349613.png)]

3.4 Table of Contents (2)

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.

打开后会在左侧出现目录。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-o05ueJDv-1639978848474)(C:UsershbwhxDesktop学习12_toolJupyterNotebookJupyterNotebook插件管理与安装.assetsimage-20211220112509327.png)]

3.5 Hinterland

Enable code autocompletion menu for every keypress in a code cell, instead of only enabling it with tab. 代码补全

3.6 Autopep8

Use kernel-specific code to reformat/prettify the contents of code cells # 代码补全功能

autopep8插件选中之后,使用时报错,报错信息如下图:

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-lMaQp01i-1639978848475)(C:UsershbwhxDesktop学习12_toolJupyterNotebookJupyterNotebook插件管理与安装.assetsimage-20211220115637976.png)]

解决办法:(tf_2.5_py_3.7) C:Usershbwhx>conda install autopep8
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-EGkTLWqS-1639978848475)(C:UsershbwhxDesktop学习12_toolJupyterNotebookJupyterNotebook插件管理与安装.assetsimage-20211220115736374.png)]

4.JupyterNotebook中kernel切换

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.

实际操作

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ABARyHi1-1639978848476)(C:UsershbwhxDesktop学习12_toolJupyterNotebookJupyterNotebook插件管理与安装.assetsimage-20211220113720990.png)]

# 激活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 的添加也可以按照此法进行。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-b54GZkIm-1639978848477)(C:UsershbwhxDesktop学习12_toolJupyterNotebookJupyterNotebook插件管理与安装.assetsimage-20211220114315330.png)]

最后

以上就是淡定帆布鞋为你收集整理的JupyterNotebook插件管理与安装JupyterNotebook插件管理与安装的全部内容,希望文章能够帮你解决JupyterNotebook插件管理与安装JupyterNotebook插件管理与安装所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部