1, themes,

Details how to create and run an IPython Notebook (an interactive computing document format based on Web technology) using PyCharm.

2. Preparation

(1) have created a project, here using C: / SampleProjects/py/IPythonNotebookExample directory of the project.

(2) In the Project Interpreter Page of the Setup dialog,

Created a virtual environment for Python.2.7.8 created a virtual environment for Python

Libraries installed the following packages:

Jinja2 IPython Matplotlib Numpy PyzMQ Tornado Sympy Of course Pycharm can help us to automatically install.

Create an IPython Notebook file

Right-click the project name and select New → File:

Enter the name and its external extension matplotlibexample.ipynb:

The Project Tool Window displays a newly created file:

Double-click to open it, which is an empty IPython Notebook file marked with a toolbar very similar to the real IPython Notebook:

4. Populate and run a file cell

Click on the first cell and enter the code. Here type the configuration code for the Matplotlib library:

Click run (or Shift+Enter) on the toolbar and Pycharm will bring up a dialog showing the URL where the IPython Notebook service is running:

Click OK:

You can open this link via your browser:

Its default URL is specified in the IPython Notebook in the Settings dialog. Next, let’s actually use IPython Notebook.

5, Use Cells

First, write the import statement:

Pycharm creates the next empty cell by default when you run the first cell:

Input code (experience spelling Assistant function) :

Click Run again. No output is displayed, but a new cell is created.

Enter the following code in the new cell;

Run this cell, error:

Variables need to be defined in advance, so we add a new cell.

6. Add cell

Click the cell where the import statement resides (the box turns green), and click the green plus sign (or Alt+Enter) :

Input variable definition code:

Run this cell first, then run the next cell, output normal:

7. Clipboard operation of cell

On the toolbar, in addition to the and buttons, there are (Ctrl+X), (Ctrl+C), and (Ctrl+V) buttons that, if clicked, delete the current cell and cache it on the clipboard.

Is paste, is copy, the rest of the button functions we experience.

8. Choose style

The drop-down menu on the right side of the toolbar is used to specify the interface style, which Rimmer considers code segmentation.

Click to create a code style cell by default. Enter the following code:

Click the drop-down arrow to select Markdown mode:

Cell appearance changes in response:

Click:

OK, then you can choose the style type you like:

9. Input format

To add a new cell, select the Markdown format and enter the following code:

Click:

As you can see, IPython Notebook implements formula editing in Latex format.

Next, try something more complex, displaying the results of the formula. Add a cell and enter the code (SymPy: Open Source Symbolic Mathematics) :

Run, no output, continue to add cell, input code:

Click and enjoy the results:

Source: CSDN Blog

This article is from SDK Community (www.sdk.cn/)