Use of an IDE Jupyter the Python

Use of an IDE Jupyter the Python

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. Advantages: easy to use, easy to use.

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.

Second, the installation

1. 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.

# 升级pip3 install --upgrade pip

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

2. After the installation is complete run

jupyter notebook

If properly installed, it may not be wrong, I am here to remind me when installed

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

So run error:

ModuleNotFoundError: No module named 'markupsafe._compat'

Suggesting that markupsafe._compat this module can not be found, so I ran to the directory Python36 \ Lib \ site-packages \ markupsafe, really, no _compat this file, and then markupsafe this module unloading, reloading, or not, Google about (now seemed popular to say, ha ha ha), find _compat the contents of the file:

# -*- coding: utf-8 -*-"""
    markupsafe._compat
    ~~~~~~~~~~~~~~~~~~
    Compatibility module for different Python versions.
    :copyright: (c) 2013 by Armin Ronacher.
    :license: BSD, see LICENSE for more details.
"""import sys
PY2 = sys.version_info[0] == 2if not PY2:
    text_type = str
    string_types = (str,)
    unichr = chr
    int_types = (int,)
    iteritems = lambda x: iter(x.items())else:
    text_type = unicode
    string_types = (str, unicode)
    unichr = unichr
    int_types = (int, long)
    iteritems = lambda x: x.iteritems()

Created in the directory Python36 \ Lib \ site-packages \ markupsafe a new file _compat.py, write the contents of the above, save, and then run cmd again next jupyther smoothly:

C:\Users\82055\Desktop>jupyter notebook
[I 17:34:01.725 NotebookApp] Writing notebook server cookie secret to C:\Users\82055\AppData\Roaming\jupyter\runtime\notebook_cookie_secret
[I 17:34:02.759 NotebookApp] Serving notebooks from local directory: C:\Users\82055\Desktop
[I 17:34:02.760 NotebookApp] 0 active kernels
[I 17:34:02.761 NotebookApp] The Jupyter Notebook is running at:
[I 17:34:02.761 NotebookApp] http://localhost:8888/?token=7d96ee52f2c5c5c451af05e15d6f6cb626b1a6783b590117
[I 17:34:02.762 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 17:34:02.764 NotebookApp]

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

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

Third, the basic use

1. Modify the default directory

(1) Find jupyter Profile Path

C:\Users\82055\Desktop> jupyter notebook --generate-config
Writing default config to: C:\Users\82055\.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 = 'H:\PyCoding'

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, move the following presentation:

Jupyter the 013-Python integrated development environment of use -02.gif

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

3.一些基本操作(gif?x-oss-process=style/watermark动图演示)

Jupyter the 013-Python integrated development environment of use -03.gif

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

四、Jupyter插件安装

  1. 不同平台安装
    1. python: pip install jupyter_contrib_nbextensions
    2. conda: conda install -c conda-forge jupyter_contrib_nbextensions
  2. 第一个步骤结束后,安装脚本文件
jupyter contrib nbextension install --user

4.1 配置

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

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

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

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

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

五、Jupyter魔术方法

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

六、Jupyter快捷键

  • Shift-Enter : 运行本单元,选中下个单元
  • Ctrl-Enter : 运行本单元
  • D,D : 删除选中的单元
  • Ctrl-Shift-- : 分割单元
  • X : 剪切选中的单元
  • C : 复制选中的单元
  • Shift-V : 粘贴到上方单元
  • V : 粘贴到下方单元
  • Z : 恢复删除的最后一个单元
  • Ctrl-A : 全选
  • Ctrl-Z : 复原
  • Shirt:选中多个单元格
  • Shirt+M:合并选中的单元格
  • shift+tab :查看当前接口的属性

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

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

7.1 解决方案1

更换默认的浏览器,选择谷歌浏览器,很多360打不开的页面,更换谷歌后都能有效解决,并且确保是最新版本的google浏览器。

7.2 解决方案2

1. Creation of jupyter_notebook_config.pya file, using the windows+rOpen command cmd command input: jupyter notebook --generate-config(note that a space behind the notebook)

In the cmd interface will prompt out, jupyter_notebook_config.pythe path of the file

2. Open the jupyter_notebook_config.pyfile, find the section (lines 95-99)# c.NotebookApp.browser = ''

## Specify what command to use to invoke a web browser when opening the notebook.
#  If not specified, the default browser will be determined by the `webbrowser`
#  standard library module, which allows setting of the BROWSER environment
#  variable to override it.
#c.NotebookApp.browser = ''

Increase below the line

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 jupyter notebook again, if not the default browser google browser, copy your computer in cmd in http://localhost:8888/?token=74493923aa071ac11d0a797133a6736296308800110bf662the Google browser.

7.3 Solution 3

  1. Home page that you can open the jupyter already installed, the page mode may be incompatibility issues
  2. At this time, right click "Switch to speed mode"
  3. After the switch, you can display the page correctly

Guess you like

Origin www.cnblogs.com/randysun/p/11710652.html