IPython Documentation - Read the Docs

IPython Documentation

Release 1.2.1: An Afternoon Hack The IPython Development Team

September 25, 2015

Contents

1 Introduction

1

1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 Enhanced interactive Python shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.3 Decoupled two-process model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.4 Interactive parallel computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 What's new in IPython

7

2.1 Development version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.2 1.0 Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.3 Issues closed in the 1.0 development cycle . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.4 0.13 Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

2.5 Issues closed in the 0.13 development cycle . . . . . . . . . . . . . . . . . . . . . . . . . . 89

2.6 0.12 Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

2.7 Issues closed in the 0.12 development cycle . . . . . . . . . . . . . . . . . . . . . . . . . . 134

2.8 0.11 Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

2.9 Issues closed in the 0.11 development cycle . . . . . . . . . . . . . . . . . . . . . . . . . . 166

2.10 0.10 series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182

2.11 0.9 series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188

2.12 0.8 series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

3 Installation

195

3.1 Quickstart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

3.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

3.3 Installing IPython itself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

3.4 Basic optional dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198

3.5 Dependencies for IPython.parallel (parallel computing) . . . . . . . . . . . . . . . . . . . . 199

3.6 Dependencies for IPython.kernel.zmq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

3.7 Dependencies for the IPython QT console . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

3.8 Dependencies for the IPython HTML notebook . . . . . . . . . . . . . . . . . . . . . . . . 200

3.9 Dependencies for nbconvert (converting notebooks to various formats) . . . . . . . . . . . 202

4 Using IPython for interactive work

203

4.1 Introducing IPython . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

i

4.2 IPython Tips & Tricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 4.3 IPython reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 4.4 IPython as a system shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 4.5 A Qt Console for IPython . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 4.6 The IPython Notebook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 4.7 Converting notebooks to other formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 4.8 Running a notebook server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

5 Using IPython for parallel computing

259

5.1 Overview and getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

5.2 Starting the IPython controller and engines . . . . . . . . . . . . . . . . . . . . . . . . . . 264

5.3 IPython's Direct interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

5.4 Parallel Magic Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

5.5 The IPython task interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295

5.6 The AsyncResult object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302

5.7 Using MPI with IPython . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306

5.8 IPython's Task Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308

5.9 Security details of IPython . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

5.10 Getting started with Windows HPC Server 2008 . . . . . . . . . . . . . . . . . . . . . . . 315

5.11 Parallel examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321

5.12 DAG Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327

5.13 Details of Parallel Computing with IPython . . . . . . . . . . . . . . . . . . . . . . . . . . 331

5.14 Transitioning from IPython.kernel to IPython.parallel . . . . . . . . . . . . . . . . . . . . . 342

6 Configuration and customization

347

6.1 Overview of the IPython configuration system . . . . . . . . . . . . . . . . . . . . . . . . 347

6.2 IPython extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355

6.3 Configuring the ipython command line application . . . . . . . . . . . . . . . . . . . . . 358

6.4 Integrating your objects with IPython . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360

6.5 Editor configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361

6.6 Custom input transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363

6.7 Outdated configuration information that might still be useful . . . . . . . . . . . . . . . . . 365

7 IPython developer's guide

371

7.1 Working with IPython source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371

7.2 Messaging in IPython . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383

7.3 Messaging for Parallel Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402

7.4 Connection Diagrams of The IPython ZMQ Cluster . . . . . . . . . . . . . . . . . . . . . 408

8 The IPython API

417

9 About IPython

419

9.1 Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419

9.2 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423

9.3 License and Copyright . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424

Bibliography

427

Python Module Index

429

ii

CHAPTER 1

Introduction

1.1 Overview

One of Python's most useful features is its interactive interpreter. It allows for very fast testing of ideas without the overhead of creating test files as is typical in most programming languages. However, the interpreter supplied with the standard Python distribution is somewhat limited for extended interactive use. The goal of IPython is to create a comprehensive environment for interactive and exploratory computing. To support this goal, IPython has three main components:

? An enhanced interactive Python shell. ? A decoupled two-process communication model, which allows for multiple clients to connect to a

computation kernel, most notably the web-based notebook ? An architecture for interactive parallel computing. All of IPython is open source (released under the revised BSD license).

1.2 Enhanced interactive Python shell

IPython's interactive shell (ipython), has the following goals, amongst others: 1. Provide an interactive shell superior to Python's default. IPython has many features for tabcompletion, object introspection, system shell access, command history retrieval across sessions, and its own special command system for adding functionality when working interactively. It tries to be a very efficient environment both for Python code development and for exploration of problems using Python objects (in situations like data analysis). 2. Serve as an embeddable, ready to use interpreter for your own programs. An interactive IPython shell can be started with a single call from inside another program, providing access to the current namespace. This can be very useful both for debugging purposes and for situations where a blend of batch-processing and interactive exploration are needed. 3. Offer a flexible framework which can be used as the base environment for working with other systems, with Python as the underlying bridge language. Specifically scientific environments like Mathematica, IDL and Matlab inspired its design, but similar ideas can be useful in many fields.

1

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download