Published online by Cambridge University Press: 05 February 2016
The IPython shell and the related interactive, browser-based IPython Notebook provide a powerful interface to the Python language. IPython has several advantages over the native Python shell, including easy interaction with the operating system, introspection and tab completion. IPython Notebook increasingly is being adopted by scientists to share their data and the code they write to analyze it in a standardized manner that aids reproducibility and visualization.
IPython
Installing IPython
Comprehensive details on installing IPython are available at the IPython website: see http://ipython.org/install.html, but a summary is provided here.
IPython is included in the Continuum Anaconda and Enthought Canopy Python distributions. To update to the current version within Anaconda, use the conda package manager:
conda update conda
conda update ipython
With Canopy, use
enpkg ipython
If you are not using these distributions but already have Python installed, there are several alternative options. If you have the pip package manager:
pip install ipython
pip install “ipython[notebook]”
It is also possible to manually download the latest IPython version from the github repository at https://github.com/ipython/ipython/releases and compile and install from its top-level source directory with
python setup.py install
Using the IPython shell
To start an interactive IPython shell session from the command line, simply type ipython. You should be greeted with a message similar to this one:
Python 3.3.5 |Anaconda 2.0.1 (x86_64)| (default, Mar 10 2014, 11:22:25)
Type “copyright”, “credits” or “license” for more information.
IPython 2.1.0 – An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about ‘object’, use ‘object??’ for extra details.
In [1]:
(The precise details of this message will depend on the setup of your system.) The prompt In [1]: is where you type your Python statements and replaces the native Python >>> shell prompt. The counter in square brackets increments with each Python statement or code block. For example,
In [1]: 4+5
Out[1]: 9
In [2]: print(1)
1
In [3]: for i in range(4):
…: print(i, end=’’)
…:
0123
In [4]:
To exit the IPython shell, type quit or exit. Unlike with the native Python shell, no parentheses are required.
To save this book to your Kindle, first ensure no-reply@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
Find out more about the Kindle Personal Document Service.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.