By continuing to navigate on this website, you accept the use of cookies to serve you more relevant services & content .
For more information and to change the setting of cookies on your computer, please read our Cookie Policy.

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

    Posted On
  • 22 January 2016
  • By
  • Micropyramid

Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
Generating PDF Files in Python using xhtml2pdf

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...
Integrate Twitter Social API into Django App

Integrating Twitter sign in (OAuth) in Django App, which includes
1. Capturing username via Twitter Login
2. Updating authenticated user current status on twitter(tweets).

Continue Reading...
Understanding Audio Quality: Bit Rate, Sample Rate

Audio Quality is the accuracy and enjoyability of the audio which the user can listen from an electronic device. Audio quality depends upon the bit ...

Continue Reading...
open source packages

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