3, Jupyter Python use of an IDE

A, Jupyter Introduction

Nature Jupyter Notebook is a Web application, easy to create and share literary program documentation, support real-time code, mathematical equations, visualization and markdown. Applications include: data cleansing and conversion, numerical simulation, statistical modeling, machine learning, and so on.

Jupyter Notebook is an algorithm engineer-friendly tool, but there are still a lot of room for expansion, for example: when your file contains a lot of code and time-shuffling, you may need a directory to help you better Markdown file structure visualization, nbextensions can help us achieve.

Jupy TE r Notebook is currently a very popular web-based development environment, it is flexible, highly scalable, not only allows users to create and share documents that contain code, you can also implanted formulas, text, visual images and descriptive, etc., data analyst is a big favorite weapon.

Second, the installation

1, the installation method

The windows, cmd used directly mounted pip

pip install jupyter

Note: Jupyter install version requires Python 3.3 or higher, or Python 2.7.

The installation process is relatively long, probably takes about 5min.

2, the installation is complete run

jupyter notebook

If properly installed, you could not go wrong.

Note: After starting notebooks, do not do not do not close the command prompt window, because once the window is closed it will disconnect from the local server.

The default will automatically jump to the page (the page)

image

3, during installation Problem

I run here jupyter notebook Shique error, as follows:

image

The last few lines shows the error.
Solution google out as follows:
in C: \ Python \ Python38 \ Lib \ site-packages \ tornado \ platform \ asyncio.py next add the following:

import sys

if sys.platform == 'win32':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
ps: the problem seems to be related to the tornado services jupyter use.

Third, the basic use

1, modify the default directory (workspace)

(1) Find jupyter Profile Path

C:\Users\bobin.yang>jupyter notebook --generate-config
Writing default config to: C:\Users\bobin.yang\.jupyter\jupyter_notebook_config.py

(2) find the configuration file, change the default directory

## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = r'C:\PycharmProjects\untitled'

Jupyter start again, find the file specified for the main page of our own files in the folder. (Defaults to desktop file)

2. Create a python file

We click on the new button on the page, create a new py3 file, as follows

image

The file name of the region of the head (the default is Untitled), click to change the file name, here we are named testas follows,

In In [ ] :the back of the input box we can enter a python test the code.

我第一次输入2+3,按Shift+Enter键运行,得出结果5,然后还可以把上面的输入更改,改为2+5,再运行,也能得出结果,这也是Jupyter的一个特性:可以修改之前的单元格,对其重新计算,这样就可以更新整个文档了。

image

Jupyter Notebooks 的强大之处在于除了能够输入代码之外,你还可以用 Markdown 添加叙述性和解释性文本。比如我想添加一个文字说明,在代码上面添加了一个单元格,并以 Markdown 输入了一个文本。按下Ctrl+Enter,效果如下:

image

3.一些基本操作

image

如何在jupyter notebook直接安装模块

!pip install 【模块名】
# 注意要加“!”

还有很多功能给大家自己开发吧,欢迎评论留言,说出你还知道的Jupyter的其他功能。

四、Jupyter插件安装

nbextensions 是 Jupyter 非常好的插件,它是将一系列 js 脚本嵌入到 Jupyter 中,增强 Jupyter 的交互式体验,可以让你的 Jupyter 变得非常强大。

1、不同平台安装

python:

pip install jupyter_contrib_nbextensions

conda:

conda install -c conda-forge jupyter_contrib_nbextensions

2、第一个步骤结束后,安装脚本文件

jupyter contrib nbextension install --user
#启用 nbextensions
jupyter nbextension enable codefolding/main

2、配置

打开 Jupyter Notebook,可以看到主界面菜单栏多出了 Nbextensions 选项,点击可以展开拓展程序选项:

image

每个拓展程序均可以单击后查看介绍与使用方法,我们以拓展目录为例。勾选红框中的Table of Contets (2)项目。然后新建一个项目,点击菜单栏的最右边新增的目录符号,即可显示文件目录。更多的设置可以点击左侧目录的设置按钮。

image

五、Jupyter魔术方法

Use Jupyter the 013-Python Integrated Development Environment -07.jpg? X-oss-process = style / watermark

六、Jupyter快捷键

    当你熟练使用notebooks的基本功能后,掌握他的快捷键是十分必要的,这样可以大大提高你的工作效率。下面是一些比较常用的快捷键:

    编辑模式:点击单元格按下Enter
    命令模式(退出编辑模式):Esc

    进入命令模式之后(此时你没有活跃单元),有以下快捷键:

    A:在所选单元之上插入一个新的单元
    B:在所选单元之下插入一个新的单元
    D:连续按两次删除所选的单元
    Z:撤销被删除的单元
    Y:将当前选中的单元变成一个代码单元
    F:查找和替换
    Shift +上或下箭头:可选择多个单元。
    Shift + M:在多选模式时,可合并你的选择。
    处于编辑模式时(在命令模式时按 Enter 会进入编辑模式),下列快捷键很有用:

    Ctrl + Home :到达单元起始位置
    Ctrl + S :保存进度
    Ctrl + Enter :会运行你的整个单元块
    Alt + Enter :不止会运行你的单元块,还会在下面添加一个新单元
    Ctrl + Shift + F :打开命令面板
    可在命令模式按 H 或进入Help > Keyboard Shortcuts。可以查看键盘快捷键完整列表。如下:

    Here Insert Picture Description

七、Jupyter后home页面空白问题解决

1、产生jupyter_notebook_config.py文件,使用windows+r打开cmd命令输入命令:jupyter notebook --generate-config(注意notebook后面有空格)

在cmd界面中会提示出,jupyter_notebook_config.py中文件的路径

2、开jupyter_notebook_config.py文件,在第(95-99行)找到 # c.NotebookApp.browser = '',在该行代码下方增加

import webbrowser
webbrowser.register('chrome', None, webbrowser.GenericBrowser(
    u'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'))
c.NotebookApp.browser = 'chrome'

Wherein the above code C:\Program Files (x86)\Google\Chrome\Application\chrome.exeis google browser path address.

3, open again jupyter notebook, if not the default browser google browser, copy your computer in cmd in http://localhost:8888/?token=74493923aa071ac11d0a797133a6736296308800110bf662the Google browser.

Guess you like

Origin www.cnblogs.com/springsnow/p/12030654.html