Python Jupyter notebook Various methods of use recording • Continuous update __python

Source: Internet
Author: User
Tags jupyter jupyter notebook
python Jupyter notebook Various use method records • Continuous Update

tags (space-delimited): Python

Pythonjupyter notebook A variety of use method records continuously update a jupyter notebook installation 1 new version Anaconda with Jupyter 2 old version Anacodna need to install Jupyter two change jupyter not Ebook Workspace 1 Mode 12 way two ace trick three jupyter a variety of shortcut keys four Jupyter notebook how to import code 1 to load a local py file into a cell in Jupyter 2 from Network Load code to jupyter five Jupy ter run Python file six jupyter some other trivial usage 1 jupyter cell can be used as UNIX command using 2 Magic functions 3 Get current working directory 4 use Matplo Markdown 1 in Tlib drawing seven Jupyter set link in Jupyter set two part 2 add directory functionality to Jupyter notebook

Jupyter notebook) Formerly known as Ipython Notebook, when learning, you can find both tutorials jupyter Project documentation jupyter Notebook documentation The jupyter/ IPython Notebook Quick Start Guide old IPython Notebook homepage One, Jupyter notebook installation 1.1 new version Anaconda with Jupy Ter Currently, the latest version of the Anaconda is brought Jupyter notebook, do not need to be installed separately
1.2 old version Anacodna need to install Jupyter

Jupyter Notebook installation of the official website

Prerequisites for installing Jupyter notebook: Python (python 2.7 or python3.3) is already installed

Specific installation methods: The official proposal to use Anaconda installation Jupyter installation completed Anaconda, if the Anaconda does not bring Jupyter Noterbook, then, open cmd, enter: Conda install Jupyter

This installed jupyter does not have the new a terminal function
After a variety of queries, it turns out that Windows does not have the terminal required TTY, so jupyter in Windows does not support terminal mode, and there is no plan to increase this support in the short term

Ii. Changing the working space of the Jupyter notebook 2.1 Mode One

"Not every time."

In its configuration file ipython_notebook_config.py, like the next sentence

# The directory to use for notebooks and kernels.
# c.notebookapp.notebook_dir = U '

This sentence is used to specify its workspace, for example, the default workspace is: User name folder, for example, now want to change the workspace to D:\Jupyter, then you need to make the following changes (remember to delete Note #)

# The directory to use for notebooks and kernels.
C.notebookapp.notebook_dir = U ' D:\Jupyter '

Note: Do not add the symbol "\" After the last level of the path

How to find the configuration file. Enter Jupyter notebook in cmd--generate-config if the configuration file already exists, the following information appears, where you can see where the configuration file exists, note that at this point, enter n and do not overwrite
If the profile does not exist, it will initialize the resulting configuration file

Enter in cmd: Ipython profile Create
Find out about the location of the Jupyter profile 2.2 way two trick (ACE) into the Working directory folder

Keyboard shift+ the right mouse button-> Open the command window here-> enter in the pop-up command window: Jupyter Notebook

Jupyter is opened to navigate to the current directory.
Three, Jupyter a variety of shortcut keys

Executes the current cell and automatically jumps to the next Cell:shift Enter

Executes the current cell and does not automatically switch to the next cell:ctrl-enter after execution

is the current cell into edit mode: Enter

Exit edit mode for the current cell: ESC

Delete the current cell: double D

Add line number to the current cell: single L

Converts the current cell into a maskdown with a first-level title: Single 1

Converts the current cell into a maskdown with a level two title: Single 2

Converts the current cell into a maskdown with a level three title: Single 3

Add/Remove comments for one or more lines: CRTL/

Undo deletion of a cell: Z

Switch between the tabs of the browser: Crtl PgUp and Crtl PgDn

Quick jump to the first CELL:CRTL home

Quick jump to the last Cell:crtl end Four, Jupyter notebook how to import code

That is, the import code into the cell in Jupyter notebook 4.1 to load the Local. py file into a cell in Jupyter

problem Background : There is a test.py file that needs to be loaded into a cell in Jupyter
test.py contents are as follows:

Import Caffe
solvername = "/root/workspace"
Sovler = Caffe. Adamsolver (Solvername)

Method Steps :
(1) Enter the cell in which you want to import the code

%load test.py #test. py is a python file under the current path

(2) Running the cell
Using the shortcut key "Shift+enter", you can see the following results:

(3) You can see that after the run,%load test.py was automatically added to the annotation symbol #,test.py all the code in the current cell was load to 4.2 from the Network load code to Jupyter

Enter%load http://... in the cell, and then run the cell to load the corresponding address on the following load into the current cell;

Here is an example of importing a small example in Matplotlib color example code

First, in the cell where you want to import the code, enter

%load test.py #test. py is a python file under the current path

Then, Shift+enter runs, you can see the following results:

As you can see, after the run,%load test.py is automatically added to the annotation symbol #,test.py all the code in the current cell is load to five, jupyter run the python file Using the Jupyter cell, you can run the Python file by running the following code in the cell:

%run file.py

file.py for the Python program you want to run, the results are displayed in the cell

Vi. Jupyter Some other trivial uses the 6.1 jupyter cell can be used as a UNIX command

To do this: add an exclamation point to the front of the UNITX command. ”

Example:
View Python version:!python--version
Run python file:!python myfile.py 6.2 Magic functions

Not too clear, specific details see the cell magics in IPython 6.3 get current working directory

The path where the currently running code is located
Concrete method: Current_path =%pwd
This gets the Current_path is the current working path of the word Fu Jing 6.4 using matplotlib drawing

In Jupyter notebook, if you use a matplotlib drawing and sometimes you can't bounce an image box, you can add it at the beginning

%matplotlib Inline
Vii. markdown in the Jupyter

Reference 1
Markdown Grammar Manual (full version) Reference 7.1 set link in jupyter, you need to set two parts:

The location to jump to (the destination)
You need to add the following statement to the location you want to jump to:

<a id= ' the_destination ' ></a>

The ID here is assigned any value, and the following link is added using the

Need to add the text of the link (an internal hyperlink to the destination), that is, click to jump to the destination, add a link after the text added:

[Text to add a connection] (#the_destination)

Here is an example:
Source:

Effect Chart:
7.2 Adding directory functionality for Jupyter notebook The original jupyter is not supporting the Markdown Add directory functionality in fact, you can use Jupyter notebook extensions to enable this functionality to achieve specific methods:
Using Anaconda to install Jupyter notebook extensions
Conda install-c Conda-forge jupyter_contrib_nbextensions
Open Jupyter Notebook and check "Table of Contents (2)" under its (Add) nbextensions tab.
Opens a. jpynb file and finds that the directory functionality is available.

Reference documents
[1] Add directory for Jupyter notebook

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.