Getting Started with the IPython Notebook

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 ""

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 ""

This will run '' and displays the output.

Posted On 22 January 2016 By MicroPyramid

Need any Help in your Project?Let's Talk

Latest Comments
Unit testing with selenium-python

Unit testing with selenium-python. Unit test case example to test the front-end

Continue Reading...
QRCode generation in python

A Quick Response code(QRCode) is a two-dimensional pictographic code used for its fast readability and comparatively large storage capacity. The code consists of black modules ...

Continue Reading...
Working with python collections part 1

Python Collections - named tuple is to access by the names specified and deque is to append and pop the elements from both sides of ...

Continue Reading...

Subscribe To our news letter

Subscribe and Stay Updated about our Webinars, news and articles on Django, Python, Machine Learning, Amazon Web Services, DevOps, Salesforce, ReactJS, AngularJS, React Native.
* We don't provide your email contact details to any third parties