IPython Notebook

* Until now we have worked directly via the interactive Python console, or by writing Python programs. IPython is a set of tools developed to make it easier for the programmers to work with Python and data.

* IPython is an enhanced Python shell, the shell being the prompt which appears when you start the python command in your terminal.

* IPython comes with notebook flavor that lets you write and execute code, analyze data in your web browser, embed content and share the work.

* IPython provides extensions to the Python programming language that make working interactively convenient and efficient. These extensions are implemented in the IPython Kernel and are available in all of the IPython Frontends (Notebook, Terminal, Console and Qt Console) when running this kernel.

Installing IPython Notebook

    $ sudo apt-get install ipython-notebook python-matplotlib

Or if you want to install using 'pip', then you can install IPython as follows:

    $ pip install ipython[notebook]

Starting IPython

To start IPython in terminal:

    $ ipython

Starting IPython Notebook

* You can interact with IPython Notebook using your web browser. You can start IPython Notebook from the command line.

* First open a terminal window, then navigate to the directory where you want to store your Python and notebook document files. Then run this command:

    $ ipython notebook or jupyter notebook

* Once IPython is running sucessfully, a browser window will automatically open or point your web browser at http://localhost:8888 to start using IPython notebooks.

First Steps with Notebook

* In the browser, click on "New Notebook" button to create a notebook. This opens a new browser window with new notebook and you can change the title by clicking on 'Untitled' on top of the page.

* An IPython notebook is made up of a number of cells. The empty box at the top is the first "cell" for entering Python code.

* You can enter set of Python statements like 'print("Hi")' in the cell and to run the code in the cell, click on 'Run' icon or press Shift+Enter.

* The output of code is displayed right after the cell. And you can see a new empty cell.

* IPython Notebooks are saved as IPython Notebook files (File extension .ipynb).

Loading Notebook Files

* You can also load IPython Notebooks files saved with '.ipynb' extension. You just need to add/move the file into your IPython Notebook directory and then choose Open file to open it.

Loading/Running Python Files

* You can load existing python files in to notebook cells by using

    $ %load "file_name.py"

and run the cell. This loads the entire file contents in to the cell.

* And you can also directly run the python file like

    $ %run "file_name.py"

This will run 'file_name.py' and displays the output.

Subscribe To our news letter

Subscribe to our news letter to receive latest blog posts into your inbox. Please fill your email address in the below form.
*We don't provide your email contact details to any third parties
Latest Comments
Related Articles
Python using yield and generators. Dinesh Deshmukh

Generators are memory efficient. They allow us to code with minimum intermediate arguments, less data structures.
Generators are of two types, generator expressions and generator ...

Continue Reading...
Understanding Python Properties Ramya Ambati

Python Properties is a class for managing class attributes in Python. Property( ) is a built-in function that creates and returns a property object

Continue Reading...

Generating PDF Files in Python using xhtml2pdf Siva Chittamuru

There are many ways for generating PDF in python. In this post I will be presenting PDF files generation with xhtml2pdf.

xhtml2pdf: xhtml2pdf is a ...

Continue Reading...