| 1 |
#LyX 1.3 created this file. For more info see http://www.lyx.org/ |
|---|
| 2 |
\lyxformat 221 |
|---|
| 3 |
\textclass article |
|---|
| 4 |
\begin_preamble |
|---|
| 5 |
\usepackage{ae,aecompl} |
|---|
| 6 |
\usepackage{hyperref} |
|---|
| 7 |
\usepackage{html} |
|---|
| 8 |
\end_preamble |
|---|
| 9 |
\language english |
|---|
| 10 |
\inputencoding latin1 |
|---|
| 11 |
\fontscheme default |
|---|
| 12 |
\graphics default |
|---|
| 13 |
\paperfontsize default |
|---|
| 14 |
\spacing single |
|---|
| 15 |
\papersize Default |
|---|
| 16 |
\paperpackage a4 |
|---|
| 17 |
\use_geometry 1 |
|---|
| 18 |
\use_amsmath 0 |
|---|
| 19 |
\use_natbib 0 |
|---|
| 20 |
\use_numerical_citations 0 |
|---|
| 21 |
\paperorientation portrait |
|---|
| 22 |
\leftmargin 1.25in |
|---|
| 23 |
\topmargin 1in |
|---|
| 24 |
\rightmargin 1.25in |
|---|
| 25 |
\bottommargin 1in |
|---|
| 26 |
\secnumdepth 3 |
|---|
| 27 |
\tocdepth 3 |
|---|
| 28 |
\paragraph_separation skip |
|---|
| 29 |
\defskip medskip |
|---|
| 30 |
\quotes_language english |
|---|
| 31 |
\quotes_times 2 |
|---|
| 32 |
\papercolumns 1 |
|---|
| 33 |
\papersides 1 |
|---|
| 34 |
\paperpagestyle fancy |
|---|
| 35 |
|
|---|
| 36 |
\layout Title |
|---|
| 37 |
|
|---|
| 38 |
IPython |
|---|
| 39 |
\newline |
|---|
| 40 |
|
|---|
| 41 |
\size larger |
|---|
| 42 |
An enhanced Interactive Python |
|---|
| 43 |
\size large |
|---|
| 44 |
|
|---|
| 45 |
\newline |
|---|
| 46 |
User Manual, v. |
|---|
| 47 |
__version__ |
|---|
| 48 |
\layout Author |
|---|
| 49 |
|
|---|
| 50 |
Fernando Pérez |
|---|
| 51 |
\layout Standard |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
\begin_inset ERT |
|---|
| 55 |
status Collapsed |
|---|
| 56 |
|
|---|
| 57 |
\layout Standard |
|---|
| 58 |
|
|---|
| 59 |
\backslash |
|---|
| 60 |
latex{ |
|---|
| 61 |
\end_inset |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
\begin_inset LatexCommand \tableofcontents{} |
|---|
| 65 |
|
|---|
| 66 |
\end_inset |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
\begin_inset ERT |
|---|
| 70 |
status Collapsed |
|---|
| 71 |
|
|---|
| 72 |
\layout Standard |
|---|
| 73 |
} |
|---|
| 74 |
\end_inset |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
\layout Standard |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
\begin_inset ERT |
|---|
| 81 |
status Open |
|---|
| 82 |
|
|---|
| 83 |
\layout Standard |
|---|
| 84 |
|
|---|
| 85 |
\backslash |
|---|
| 86 |
html{ |
|---|
| 87 |
\backslash |
|---|
| 88 |
bodytext{bgcolor=#ffffff}} |
|---|
| 89 |
\end_inset |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
\layout Section |
|---|
| 93 |
\pagebreak_top |
|---|
| 94 |
Overview |
|---|
| 95 |
\layout Standard |
|---|
| 96 |
|
|---|
| 97 |
One of Python's most useful features is its interactive interpreter. |
|---|
| 98 |
This system allows very fast testing of ideas without the overhead of creating |
|---|
| 99 |
test files as is typical in most programming languages. |
|---|
| 100 |
However, the interpreter supplied with the standard Python distribution |
|---|
| 101 |
is somewhat limited for extended interactive use. |
|---|
| 102 |
\layout Standard |
|---|
| 103 |
|
|---|
| 104 |
IPython is a free software project (released under the BSD license) which |
|---|
| 105 |
tries to: |
|---|
| 106 |
\layout Enumerate |
|---|
| 107 |
|
|---|
| 108 |
Provide an interactive shell superior to Python's default. |
|---|
| 109 |
IPython has many features for object introspection, system shell access, |
|---|
| 110 |
and its own special command system for adding functionality when working |
|---|
| 111 |
interactively. |
|---|
| 112 |
It tries to be a very efficient environment both for Python code development |
|---|
| 113 |
and for exploration of problems using Python objects (in situations like |
|---|
| 114 |
data analysis). |
|---|
| 115 |
\layout Enumerate |
|---|
| 116 |
|
|---|
| 117 |
Serve as an embeddable, ready to use interpreter for your own programs. |
|---|
| 118 |
IPython can be started with a single call from inside another program, |
|---|
| 119 |
providing access to the current namespace. |
|---|
| 120 |
This can be very useful both for debugging purposes and for situations |
|---|
| 121 |
where a blend of batch-processing and interactive exploration are needed. |
|---|
| 122 |
\layout Enumerate |
|---|
| 123 |
|
|---|
| 124 |
Offer a flexible framework which can be used as the base environment for |
|---|
| 125 |
other systems with Python as the underlying language. |
|---|
| 126 |
Specifically scientific environments like Mathematica, IDL and Matlab inspired |
|---|
| 127 |
its design, but similar ideas can be useful in many fields. |
|---|
| 128 |
\layout Subsection |
|---|
| 129 |
|
|---|
| 130 |
Main features |
|---|
| 131 |
\layout Itemize |
|---|
| 132 |
|
|---|
| 133 |
Dynamic object introspection. |
|---|
| 134 |
One can access docstrings, function definition prototypes, source code, |
|---|
| 135 |
source files and other details of any object accessible to the interpreter |
|---|
| 136 |
with a single keystroke (` |
|---|
| 137 |
\family typewriter |
|---|
| 138 |
? |
|---|
| 139 |
\family default |
|---|
| 140 |
'). |
|---|
| 141 |
\layout Itemize |
|---|
| 142 |
|
|---|
| 143 |
Completion in the local namespace, by typing TAB at the prompt. |
|---|
| 144 |
This works for keywords, methods, variables and files in the current directory. |
|---|
| 145 |
This is supported via the readline library, and full access to configuring |
|---|
| 146 |
readline's behavior is provided. |
|---|
| 147 |
\layout Itemize |
|---|
| 148 |
|
|---|
| 149 |
Numbered input/output prompts with command history (persistent across sessions |
|---|
| 150 |
and tied to each profile), full searching in this history and caching of |
|---|
| 151 |
all input and output. |
|---|
| 152 |
\layout Itemize |
|---|
| 153 |
|
|---|
| 154 |
User-extensible `magic' commands. |
|---|
| 155 |
A set of commands prefixed with |
|---|
| 156 |
\family typewriter |
|---|
| 157 |
% |
|---|
| 158 |
\family default |
|---|
| 159 |
is available for controlling IPython itself and provides directory control, |
|---|
| 160 |
namespace information and many aliases to common system shell commands. |
|---|
| 161 |
\layout Itemize |
|---|
| 162 |
|
|---|
| 163 |
Alias facility for defining your own system aliases. |
|---|
| 164 |
\layout Itemize |
|---|
| 165 |
|
|---|
| 166 |
Complete system shell access. |
|---|
| 167 |
Lines starting with ! are passed directly to the system shell, and using |
|---|
| 168 |
!! captures shell output into python variables for further use. |
|---|
| 169 |
\layout Itemize |
|---|
| 170 |
|
|---|
| 171 |
All calls to the system (via aliases or via !) have their standard output/error |
|---|
| 172 |
automatically stored as strings, and also available as lists. |
|---|
| 173 |
\layout Itemize |
|---|
| 174 |
|
|---|
| 175 |
Background execution of Python commands in a separate thread. |
|---|
| 176 |
IPython has an internal job manager called |
|---|
| 177 |
\family typewriter |
|---|
| 178 |
jobs |
|---|
| 179 |
\family default |
|---|
| 180 |
, and a conveninence backgrounding magic function called |
|---|
| 181 |
\family typewriter |
|---|
| 182 |
%bg |
|---|
| 183 |
\family default |
|---|
| 184 |
. |
|---|
| 185 |
\layout Itemize |
|---|
| 186 |
|
|---|
| 187 |
The ability to expand python variables when calling the system shell. |
|---|
| 188 |
In a shell command, any python variable prefixed with |
|---|
| 189 |
\family typewriter |
|---|
| 190 |
$ |
|---|
| 191 |
\family default |
|---|
| 192 |
is expanded. |
|---|
| 193 |
A double |
|---|
| 194 |
\family typewriter |
|---|
| 195 |
$$ |
|---|
| 196 |
\family default |
|---|
| 197 |
allows passing a literal |
|---|
| 198 |
\family typewriter |
|---|
| 199 |
$ |
|---|
| 200 |
\family default |
|---|
| 201 |
to the shell (for access to shell and environment variables like |
|---|
| 202 |
\family typewriter |
|---|
| 203 |
$PATH |
|---|
| 204 |
\family default |
|---|
| 205 |
). |
|---|
| 206 |
\layout Itemize |
|---|
| 207 |
|
|---|
| 208 |
Filesystem navigation, via a magic |
|---|
| 209 |
\family typewriter |
|---|
| 210 |
%cd |
|---|
| 211 |
\family default |
|---|
| 212 |
command, along with a persistent bookmark system (using |
|---|
| 213 |
\family typewriter |
|---|
| 214 |
%bookmark |
|---|
| 215 |
\family default |
|---|
| 216 |
) for fast access to frequently visited directories. |
|---|
| 217 |
\layout Itemize |
|---|
| 218 |
|
|---|
| 219 |
Automatic indentation (optional) of code as you type (through the readline |
|---|
| 220 |
library). |
|---|
| 221 |
\layout Itemize |
|---|
| 222 |
|
|---|
| 223 |
Macro system for quickly re-executing multiple lines of previous input with |
|---|
| 224 |
a single name. |
|---|
| 225 |
\layout Itemize |
|---|
| 226 |
|
|---|
| 227 |
Session logging (you can then later use these logs as code in your programs). |
|---|
| 228 |
\layout Itemize |
|---|
| 229 |
|
|---|
| 230 |
Session restoring: logs can be replayed to restore a previous session to |
|---|
| 231 |
the state where you left it. |
|---|
| 232 |
\layout Itemize |
|---|
| 233 |
|
|---|
| 234 |
Verbose and colored exception traceback printouts. |
|---|
| 235 |
Easier to parse visually, and in verbose mode they produce a lot of useful |
|---|
| 236 |
debugging information (basically a terminal version of the cgitb module). |
|---|
| 237 |
\layout Itemize |
|---|
| 238 |
|
|---|
| 239 |
Auto-parentheses: callable objects can be executed without parentheses: |
|---|
| 240 |
|
|---|
| 241 |
\family typewriter |
|---|
| 242 |
`sin 3' |
|---|
| 243 |
\family default |
|---|
| 244 |
is automatically converted to |
|---|
| 245 |
\family typewriter |
|---|
| 246 |
`sin(3) |
|---|
| 247 |
\family default |
|---|
| 248 |
'. |
|---|
| 249 |
\layout Itemize |
|---|
| 250 |
|
|---|
| 251 |
Auto-quoting: using ` |
|---|
| 252 |
\family typewriter |
|---|
| 253 |
, |
|---|
| 254 |
\family default |
|---|
| 255 |
' or ` |
|---|
| 256 |
\family typewriter |
|---|
| 257 |
; |
|---|
| 258 |
\family default |
|---|
| 259 |
' as the first character forces auto-quoting of the rest of the line: |
|---|
| 260 |
\family typewriter |
|---|
| 261 |
`,my_function a\SpecialChar ~ |
|---|
| 262 |
b' |
|---|
| 263 |
\family default |
|---|
| 264 |
becomes automatically |
|---|
| 265 |
\family typewriter |
|---|
| 266 |
`my_function("a","b")' |
|---|
| 267 |
\family default |
|---|
| 268 |
, while |
|---|
| 269 |
\family typewriter |
|---|
| 270 |
`;my_function a\SpecialChar ~ |
|---|
| 271 |
b' |
|---|
| 272 |
\family default |
|---|
| 273 |
becomes |
|---|
| 274 |
\family typewriter |
|---|
| 275 |
`my_function("a b")' |
|---|
| 276 |
\family default |
|---|
| 277 |
. |
|---|
| 278 |
\layout Itemize |
|---|
| 279 |
|
|---|
| 280 |
Extensible input syntax. |
|---|
| 281 |
You can define filters that pre-process user input to simplify input in |
|---|
| 282 |
special situations. |
|---|
| 283 |
This allows for example pasting multi-line code fragments which start with |
|---|
| 284 |
|
|---|
| 285 |
\family typewriter |
|---|
| 286 |
`>>>' |
|---|
| 287 |
\family default |
|---|
| 288 |
or |
|---|
| 289 |
\family typewriter |
|---|
| 290 |
`...' |
|---|
| 291 |
\family default |
|---|
| 292 |
such as those from other python sessions or the standard Python documentation. |
|---|
| 293 |
\layout Itemize |
|---|
| 294 |
|
|---|
| 295 |
Flexible configuration system. |
|---|
| 296 |
It uses a configuration file which allows permanent setting of all command-line |
|---|
| 297 |
options, module loading, code and file execution. |
|---|
| 298 |
The system allows recursive file inclusion, so you can have a base file |
|---|
| 299 |
with defaults and layers which load other customizations for particular |
|---|
| 300 |
projects. |
|---|
| 301 |
\layout Itemize |
|---|
| 302 |
|
|---|
| 303 |
Embeddable. |
|---|
| 304 |
You can call IPython as a python shell inside your own python programs. |
|---|
| 305 |
This can be used both for debugging code or for providing interactive abilities |
|---|
| 306 |
to your programs with knowledge about the local namespaces (very useful |
|---|
| 307 |
in debugging and data analysis situations). |
|---|
| 308 |
\layout Itemize |
|---|
| 309 |
|
|---|
| 310 |
Easy debugger access. |
|---|
| 311 |
You can set IPython to call up the Python debugger (pdb) every time there |
|---|
| 312 |
is an uncaught exception. |
|---|
| 313 |
This drops you inside the code which triggered the exception with all the |
|---|
| 314 |
data live and it is possible to navigate the stack to rapidly isolate the |
|---|
| 315 |
source of a bug. |
|---|
| 316 |
The |
|---|
| 317 |
\family typewriter |
|---|
| 318 |
%run |
|---|
| 319 |
\family default |
|---|
| 320 |
magic command --with the |
|---|
| 321 |
\family typewriter |
|---|
| 322 |
-d |
|---|
| 323 |
\family default |
|---|
| 324 |
option-- can run any script under |
|---|
| 325 |
\family typewriter |
|---|
| 326 |
pdb |
|---|
| 327 |
\family default |
|---|
| 328 |
's control, automatically setting initial breakpoints for you. |
|---|
| 329 |
\layout Itemize |
|---|
| 330 |
|
|---|
| 331 |
Profiler support. |
|---|
| 332 |
You can run single statements (similar to |
|---|
| 333 |
\family typewriter |
|---|
| 334 |
profile.run() |
|---|
| 335 |
\family default |
|---|
| 336 |
) or complete programs under the profiler's control. |
|---|
| 337 |
While this is possible with the standard |
|---|
| 338 |
\family typewriter |
|---|
| 339 |
profile |
|---|
| 340 |
\family default |
|---|
| 341 |
module, IPython wraps this functionality with magic commands (see |
|---|
| 342 |
\family typewriter |
|---|
| 343 |
`%prun' |
|---|
| 344 |
\family default |
|---|
| 345 |
and |
|---|
| 346 |
\family typewriter |
|---|
| 347 |
`%run -p |
|---|
| 348 |
\family default |
|---|
| 349 |
') convenient for rapid interactive work. |
|---|
| 350 |
\layout Subsection |
|---|
| 351 |
|
|---|
| 352 |
Portability and Python requirements |
|---|
| 353 |
\layout Standard |
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
\series bold |
|---|
| 357 |
Python requirements: |
|---|
| 358 |
\series default |
|---|
| 359 |
IPython works with Python version 2.2 or newer. |
|---|
| 360 |
It has been tested with Python 2.4 and no problems have been reported. |
|---|
| 361 |
Support for Python 2.1 hasn't been recently tested, since I don't have access |
|---|
| 362 |
to it on any of my systems. |
|---|
| 363 |
But I suspect there may be some problems with Python 2.1, because some of |
|---|
| 364 |
the newer code may use 2.2 features. |
|---|
| 365 |
\layout Standard |
|---|
| 366 |
|
|---|
| 367 |
IPython is developed under |
|---|
| 368 |
\series bold |
|---|
| 369 |
Linux |
|---|
| 370 |
\series default |
|---|
| 371 |
, but it should work in any reasonable Unix-type system (tested OK under |
|---|
| 372 |
Solaris and the *BSD family, for which a port exists thanks to Dryice Liu). |
|---|
| 373 |
\layout Standard |
|---|
| 374 |
|
|---|
| 375 |
|
|---|
| 376 |
\series bold |
|---|
| 377 |
Mac OS X |
|---|
| 378 |
\series default |
|---|
| 379 |
: it works, apparently without any problems (thanks to Jim Boyle at Lawrence |
|---|
| 380 |
Livermore for the information). |
|---|
| 381 |
Thanks to Andrea Riciputi, Fink support is available. |
|---|
| 382 |
\layout Standard |
|---|
| 383 |
|
|---|
| 384 |
|
|---|
| 385 |
\series bold |
|---|
| 386 |
CygWin |
|---|
| 387 |
\series default |
|---|
| 388 |
: it works mostly OK, though some users have reported problems with prompt |
|---|
| 389 |
coloring. |
|---|
| 390 |
No satisfactory solution to this has been found so far, you may want to |
|---|
| 391 |
disable colors permanently in the |
|---|
| 392 |
\family typewriter |
|---|
| 393 |
ipythonrc |
|---|
| 394 |
\family default |
|---|
| 395 |
configuration file if you experience problems. |
|---|
| 396 |
If you have proper color support under cygwin, please post to the IPython |
|---|
| 397 |
mailing list so this issue can be resolved for all users. |
|---|
| 398 |
\layout Standard |
|---|
| 399 |
|
|---|
| 400 |
|
|---|
| 401 |
\series bold |
|---|
| 402 |
Windows |
|---|
| 403 |
\series default |
|---|
| 404 |
: it works well under Windows XP/2k, and I suspect NT should behave similarly. |
|---|
| 405 |
Section\SpecialChar ~ |
|---|
| 406 |
|
|---|
| 407 |
\begin_inset LatexCommand \ref{sub:Under-Windows} |
|---|
| 408 |
|
|---|
| 409 |
\end_inset |
|---|
| 410 |
|
|---|
| 411 |
describes installation details for Windows, including some additional tools |
|---|
| 412 |
needed on this platform. |
|---|
| 413 |
\layout Standard |
|---|
| 414 |
|
|---|
| 415 |
Windows 9x support is present, and has been reported to work fine (at least |
|---|
| 416 |
on WinME). |
|---|
| 417 |
\layout Standard |
|---|
| 418 |
|
|---|
| 419 |
Please note, however, that I have very little access to and experience with |
|---|
| 420 |
Windows development. |
|---|
| 421 |
For this reason, Windows-specific bugs tend to linger far longer than I |
|---|
| 422 |
would like, and often I just can't find a satisfactory solution. |
|---|
| 423 |
If any Windows user wants to join in with development help, all hands are |
|---|
| 424 |
always welcome. |
|---|
| 425 |
\layout Subsection |
|---|
| 426 |
|
|---|
| 427 |
Location |
|---|
| 428 |
\layout Standard |
|---|
| 429 |
|
|---|
| 430 |
IPython is generously hosted at |
|---|
| 431 |
\begin_inset LatexCommand \htmlurl{http://ipython.scipy.org} |
|---|
| 432 |
|
|---|
| 433 |
\end_inset |
|---|
| 434 |
|
|---|
| 435 |
by the SciPy project. |
|---|
| 436 |
This site offers downloads, CVS access, mailing lists and a bug tracking |
|---|
| 437 |
system. |
|---|
| 438 |
I am very grateful to Enthought ( |
|---|
| 439 |
\begin_inset LatexCommand \htmlurl{http://www.enthought.com} |
|---|
| 440 |
|
|---|
| 441 |
\end_inset |
|---|
| 442 |
|
|---|
| 443 |
) and all of the SciPy team for their contribution. |
|---|
| 444 |
\layout Section |
|---|
| 445 |
|
|---|
| 446 |
|
|---|
| 447 |
\begin_inset LatexCommand \label{sec:install} |
|---|
| 448 |
|
|---|
| 449 |
\end_inset |
|---|
| 450 |
|
|---|
| 451 |
Installation |
|---|
| 452 |
\layout Subsection |
|---|
| 453 |
|
|---|
| 454 |
Instant instructions |
|---|
| 455 |
\layout Standard |
|---|
| 456 |
|
|---|
| 457 |
If you are of the impatient kind, under Linux/Unix simply untar/unzip the |
|---|
| 458 |
download, then install with |
|---|
| 459 |
\family typewriter |
|---|
| 460 |
`python setup.py install' |
|---|
| 461 |
\family default |
|---|
| 462 |
. |
|---|
| 463 |
Under Windows, double-click on the provided |
|---|
| 464 |
\family typewriter |
|---|
| 465 |
.exe |
|---|
| 466 |
\family default |
|---|
| 467 |
binary installer. |
|---|
| 468 |
\layout Standard |
|---|
| 469 |
|
|---|
| 470 |
Then, take a look at Sections |
|---|
| 471 |
\begin_inset LatexCommand \ref{sec:good_config} |
|---|
| 472 |
|
|---|
| 473 |
\end_inset |
|---|
| 474 |
|
|---|
| 475 |
for configuring things optimally and |
|---|
| 476 |
\begin_inset LatexCommand \ref{sec:quick_tips} |
|---|
| 477 |
|
|---|
| 478 |
\end_inset |
|---|
| 479 |
|
|---|
| 480 |
for quick tips on efficient use of IPython. |
|---|
| 481 |
You can later refer to the rest of the manual for all the gory details. |
|---|
| 482 |
\layout Standard |
|---|
| 483 |
|
|---|
| 484 |
See the notes in sec. |
|---|
| 485 |
|
|---|
| 486 |
\begin_inset LatexCommand \ref{sec:upgrade} |
|---|
| 487 |
|
|---|
| 488 |
\end_inset |
|---|
| 489 |
|
|---|
| 490 |
for upgrading IPython versions. |
|---|
| 491 |
\layout Subsection |
|---|
| 492 |
|
|---|
| 493 |
Detailed Unix instructions (Linux, Mac OS X, etc.) |
|---|
| 494 |
\layout Standard |
|---|
| 495 |
|
|---|
| 496 |
|
|---|
| 497 |
\begin_inset ERT |
|---|
| 498 |
status Open |
|---|
| 499 |
|
|---|
| 500 |
\layout Standard |
|---|
| 501 |
|
|---|
| 502 |
\backslash |
|---|
| 503 |
html{ |
|---|
| 504 |
\backslash |
|---|
| 505 |
textbf{A warning to readers of the HTML version of this manual}: all options below are preceded with with TWO dashes and no intervening space between the dashes (e.g. Dash-Dash-home). The default HTML conversion tools mangle these into a single dash.} |
|---|
| 506 |
\end_inset |
|---|
| 507 |
|
|---|
| 508 |
|
|---|
| 509 |
\layout Standard |
|---|
| 510 |
|
|---|
| 511 |
For RPM based systems, simply install the supplied package in the usual |
|---|
| 512 |
manner. |
|---|
| 513 |
If you download the tar archive, the process is: |
|---|
| 514 |
\layout Enumerate |
|---|
| 515 |
|
|---|
| 516 |
Unzip/untar the |
|---|
| 517 |
\family typewriter |
|---|
| 518 |
ipython-XXX.tar.gz |
|---|
| 519 |
\family default |
|---|
| 520 |
file wherever you want ( |
|---|
| 521 |
\family typewriter |
|---|
| 522 |
XXX |
|---|
| 523 |
\family default |
|---|
| 524 |
is the version number). |
|---|
| 525 |
It will make a directory called |
|---|
| 526 |
\family typewriter |
|---|
| 527 |
ipython-XXX. |
|---|
| 528 |
|
|---|
| 529 |
\family default |
|---|
| 530 |
Change into that directory where you will find the files |
|---|
| 531 |
\family typewriter |
|---|
| 532 |
README |
|---|
| 533 |
\family default |
|---|
| 534 |
and |
|---|
| 535 |
\family typewriter |
|---|
| 536 |
setup.py |
|---|
| 537 |
\family default |
|---|
| 538 |
. |
|---|
| 539 |
|
|---|
| 540 |
\family typewriter |
|---|
| 541 |
O |
|---|
| 542 |
\family default |
|---|
| 543 |
nce you've completed the installation, you can safely remove this directory. |
|---|
| 544 |
|
|---|
| 545 |
\layout Enumerate |
|---|
| 546 |
|
|---|
| 547 |
If you are installing over a previous installation of version 0.2.0 or earlier, |
|---|
| 548 |
first remove your |
|---|
| 549 |
\family typewriter |
|---|
| 550 |
$HOME/.ipython |
|---|
| 551 |
\family default |
|---|
| 552 |
directory, since the configuration file format has changed somewhat (the |
|---|
| 553 |
'=' were removed from all option specifications). |
|---|
| 554 |
Or you can call ipython with the |
|---|
| 555 |
\family typewriter |
|---|
| 556 |
-upgrade |
|---|
| 557 |
\family default |
|---|
| 558 |
option and it will do this automatically for you. |
|---|
| 559 |
\layout Enumerate |
|---|
| 560 |
|
|---|
| 561 |
IPython uses distutils, so you can install it by simply typing at the system |
|---|
| 562 |
prompt (don't type the |
|---|
| 563 |
\family typewriter |
|---|
| 564 |
$ |
|---|
| 565 |
\family default |
|---|
| 566 |
) |
|---|
| 567 |
\newline |
|---|
| 568 |
|
|---|
| 569 |
\family typewriter |
|---|
| 570 |
$ python setup.py install |
|---|
| 571 |
\family default |
|---|
| 572 |
|
|---|
| 573 |
\newline |
|---|
| 574 |
Note that this assumes you have root access to your machine. |
|---|
| 575 |
If you don't have root access or don't want IPython to go in the default |
|---|
| 576 |
python directories, you'll need to use the |
|---|
| 577 |
\family typewriter |
|---|
| 578 |
--home |
|---|
| 579 |
\family default |
|---|
| 580 |
option (or |
|---|
| 581 |
\family typewriter |
|---|
| 582 |
--prefix |
|---|
| 583 |
\family default |
|---|
| 584 |
). |
|---|
| 585 |
For example: |
|---|
| 586 |
\newline |
|---|
| 587 |
|
|---|
| 588 |
\family typewriter |
|---|
| 589 |
$ python setup.py install --home $HOME/local |
|---|
| 590 |
\family default |
|---|
| 591 |
|
|---|
| 592 |
\newline |
|---|
| 593 |
will install |
|---|
| 594 |
\begin_inset Foot |
|---|
| 595 |
collapsed true |
|---|
| 596 |
|
|---|
| 597 |
\layout Standard |
|---|
| 598 |
|
|---|
| 599 |
If you are reading these instructions in HTML format, please note that the |
|---|
| 600 |
option is --home, with |
|---|
| 601 |
\emph on |
|---|
| 602 |
two |
|---|
| 603 |
\emph default |
|---|
| 604 |
dashes. |
|---|
| 605 |
The automatic HTML conversion program seems to eat up one of the dashes, |
|---|
| 606 |
unfortunately (it's ok in the PDF version). |
|---|
| 607 |
\end_inset |
|---|
| 608 |
|
|---|
| 609 |
IPython into |
|---|
| 610 |
\family typewriter |
|---|
| 611 |
$HOME/local |
|---|
| 612 |
\family default |
|---|
| 613 |
and its subdirectories (creating them if necessary). |
|---|
| 614 |
\newline |
|---|
| 615 |
You can type |
|---|
| 616 |
\newline |
|---|
| 617 |
|
|---|
| 618 |
\family typewriter |
|---|
| 619 |
$ python setup.py --help |
|---|
| 620 |
\family default |
|---|
| 621 |
|
|---|
| 622 |
\newline |
|---|
| 623 |
for more details. |
|---|
| 624 |
\newline |
|---|
| 625 |
Note that if you change the default location for |
|---|
| 626 |
\family typewriter |
|---|
| 627 |
--home |
|---|
| 628 |
\family default |
|---|
| 629 |
at installation, IPython may end up installed at a location which is not |
|---|
| 630 |
part of your |
|---|
| 631 |
\family typewriter |
|---|
| 632 |
$PYTHONPATH |
|---|
| 633 |
\family default |
|---|
| 634 |
environment variable. |
|---|
| 635 |
In this case, you'll need to configure this variable to include the actual |
|---|
| 636 |
directory where the |
|---|
| 637 |
\family typewriter |
|---|
| 638 |
IPython/ |
|---|
| 639 |
\family default |
|---|
| 640 |
directory ended (typically the value you give to |
|---|
| 641 |
\family typewriter |
|---|
| 642 |
--home |
|---|
| 643 |
\family default |
|---|
| 644 |
plus |
|---|
| 645 |
\family typewriter |
|---|
| 646 |
/lib/python |
|---|
| 647 |
\family default |
|---|
| 648 |
). |
|---|
| 649 |
\layout Subsubsection |
|---|
| 650 |
|
|---|
| 651 |
Mac OSX information |
|---|
| 652 |
\layout Subsubsection* |
|---|
| 653 |
|
|---|
| 654 |
GUI problems |
|---|
| 655 |
\layout Standard |
|---|
| 656 |
|
|---|
| 657 |
The following instructions apply to an install of IPython under OSX from |
|---|
| 658 |
unpacking the |
|---|
| 659 |
\family typewriter |
|---|
| 660 |
.tar.gz |
|---|
| 661 |
\family default |
|---|
| 662 |
distribution and installing it for the default Python interpreter shipped |
|---|
| 663 |
by Apple. |
|---|
| 664 |
If you are using a fink install, fink will take care of these details for |
|---|
| 665 |
you, by installing IPython against fink's Python. |
|---|
| 666 |
\layout Standard |
|---|
| 667 |
|
|---|
| 668 |
IPython offers various forms of support for interacting with graphical applicati |
|---|
| 669 |
ons from the command line, from simple Tk apps (which are in principle always |
|---|
| 670 |
supported by Python) to interactive control of WX, QT and GTK apps. |
|---|
| 671 |
Under OSX, however, this requires that ipython is installed by calling |
|---|
| 672 |
the special |
|---|
| 673 |
\family typewriter |
|---|
| 674 |
pythonw |
|---|
| 675 |
\family default |
|---|
| 676 |
script at installation time, which takes care of coordinating things with |
|---|
| 677 |
Apple's graphical environment. |
|---|
| 678 |
\layout Standard |
|---|
| 679 |
|
|---|
| 680 |
So when installing under OSX, it is best to use the following command |
|---|
| 681 |
\begin_inset ERT |
|---|
| 682 |
status Collapsed |
|---|
| 683 |
|
|---|
| 684 |
\layout Standard |
|---|
| 685 |
|
|---|
| 686 |
\backslash |
|---|
| 687 |
html{ |
|---|
| 688 |
\backslash |
|---|
| 689 |
emph{[Again, in the HTML manual, the option is called -~-install=scripts, with TWO dashes and no intervening space between the dashes]}} |
|---|
| 690 |
\end_inset |
|---|
| 691 |
|
|---|
| 692 |
: |
|---|
| 693 |
\family typewriter |
|---|
| 694 |
|
|---|
| 695 |
\newline |
|---|
| 696 |
\SpecialChar ~ |
|---|
| 697 |
\SpecialChar ~ |
|---|
| 698 |
$ sudo pythonw setup.py install --install-scripts=/usr/local/bin |
|---|
| 699 |
\family default |
|---|
| 700 |
|
|---|
| 701 |
\newline |
|---|
| 702 |
or |
|---|
| 703 |
\family typewriter |
|---|
| 704 |
|
|---|
| 705 |
\newline |
|---|
| 706 |
\SpecialChar ~ |
|---|
| 707 |
\SpecialChar ~ |
|---|
| 708 |
$ sudo pythonw setup.py install --install-scripts=/usr/bin |
|---|
| 709 |
\newline |
|---|
| 710 |
|
|---|
| 711 |
\family default |
|---|
| 712 |
depending on where you like to keep hand-installed executables. |
|---|
| 713 |
\layout Standard |
|---|
| 714 |
|
|---|
| 715 |
The resulting script will have an appropriate shebang line (the first line |
|---|
| 716 |
in the script whic begins with |
|---|
| 717 |
\family typewriter |
|---|
| 718 |
#!... |
|---|
| 719 |
\family default |
|---|
| 720 |
) such that the ipython interpreter can interact with the OS X GUI. |
|---|
| 721 |
If the installed version does not work and has a shebang line that points |
|---|
| 722 |
to, for example, just |
|---|
| 723 |
\family typewriter |
|---|
| 724 |
/usr/bin/python |
|---|
| 725 |
\family default |
|---|
| 726 |
, then you might have a stale, cached version in your |
|---|
| 727 |
\family typewriter |
|---|
| 728 |
build/scripts-<python-version> |
|---|
| 729 |
\family default |
|---|
| 730 |
directory. |
|---|
| 731 |
Delete that directory and rerun the |
|---|
| 732 |
\family typewriter |
|---|
| 733 |
setup.py |
|---|
| 734 |
\family default |
|---|
| 735 |
. |
|---|
| 736 |
|
|---|
| 737 |
\layout Standard |
|---|
| 738 |
|
|---|
| 739 |
It is also a good idea to use the special flag |
|---|
| 740 |
\family typewriter |
|---|
| 741 |
--install-scripts |
|---|
| 742 |
\family default |
|---|
| 743 |
as indicated above, to ensure that the ipython scripts end up in a location |
|---|
| 744 |
which is part of your |
|---|
| 745 |
\family typewriter |
|---|
| 746 |
$PATH |
|---|
| 747 |
\family default |
|---|
| 748 |
. |
|---|
| 749 |
Otherwise Apple's Python will put the scripts in an internal directory |
|---|
| 750 |
not available by default at the command line (if you use |
|---|
| 751 |
\family typewriter |
|---|
| 752 |
/usr/local/bin |
|---|
| 753 |
\family default |
|---|
| 754 |
, you need to make sure this is in your |
|---|
| 755 |
\family typewriter |
|---|
| 756 |
$PATH |
|---|
| 757 |
\family default |
|---|
| 758 |
, which may not be true by default). |
|---|
| 759 |
\layout Subsubsection* |
|---|
| 760 |
|
|---|
| 761 |
Readline problems |
|---|
| 762 |
\layout Standard |
|---|
| 763 |
|
|---|
| 764 |
By default, the Python version shipped by Apple does |
|---|
| 765 |
\emph on |
|---|
| 766 |
not |
|---|
| 767 |
\emph default |
|---|
| 768 |
include the readline library, so central to IPython's behavior. |
|---|
| 769 |
If you install IPython against Apple's Python, you will not have arrow |
|---|
| 770 |
keys, tab completion, etc. |
|---|
| 771 |
For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here: |
|---|
| 772 |
\newline |
|---|
| 773 |
|
|---|
| 774 |
\begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip} |
|---|
| 775 |
|
|---|
| 776 |
\end_inset |
|---|
| 777 |
|
|---|
| 778 |
|
|---|
| 779 |
\layout Standard |
|---|
| 780 |
|
|---|
| 781 |
At this point I don't know of such a released version for OSX 10.4 (Tiger), |
|---|
| 782 |
or if the problem even occurs with Tiger at all (feedback welcome). |
|---|
| 783 |
\layout Standard |
|---|
| 784 |
|
|---|
| 785 |
Users installing against fink's Python or a properly hand-built one should |
|---|
| 786 |
not have this problem. |
|---|
| 787 |
\layout Subsection |
|---|
| 788 |
|
|---|
| 789 |
|
|---|
| 790 |
\begin_inset LatexCommand \label{sub:Under-Windows} |
|---|
| 791 |
|
|---|
| 792 |
\end_inset |
|---|
| 793 |
|
|---|
| 794 |
Windows instructions |
|---|
| 795 |
\layout Standard |
|---|
| 796 |
|
|---|
| 797 |
While you can use IPython under Windows with only a stock Python installation, |
|---|
| 798 |
there is one extension, |
|---|
| 799 |
\family typewriter |
|---|
| 800 |
readline |
|---|
| 801 |
\family default |
|---|
| 802 |
, which will make the whole experience a lot more pleasant. |
|---|
| 803 |
It is almost a requirement, since IPython will complain in its absence |
|---|
| 804 |
(though it will function). |
|---|
| 805 |
|
|---|
| 806 |
\layout Standard |
|---|
| 807 |
|
|---|
| 808 |
The |
|---|
| 809 |
\family typewriter |
|---|
| 810 |
readline |
|---|
| 811 |
\family default |
|---|
| 812 |
extension needs two other libraries to work, so in all you need: |
|---|
| 813 |
\layout Enumerate |
|---|
| 814 |
|
|---|
| 815 |
|
|---|
| 816 |
\family typewriter |
|---|
| 817 |
PyWin32 |
|---|
| 818 |
\family default |
|---|
| 819 |
from |
|---|
| 820 |
\begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond} |
|---|
| 821 |
|
|---|
| 822 |
\end_inset |
|---|
| 823 |
|
|---|
| 824 |
. |
|---|
| 825 |
\layout Enumerate |
|---|
| 826 |
|
|---|
| 827 |
|
|---|
| 828 |
\family typewriter |
|---|
| 829 |
CTypes |
|---|
| 830 |
\family default |
|---|
| 831 |
from |
|---|
| 832 |
\begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes} |
|---|
| 833 |
|
|---|
| 834 |
\end_inset |
|---|
| 835 |
|
|---|
| 836 |
(you |
|---|
| 837 |
\emph on |
|---|
| 838 |
must |
|---|
| 839 |
\emph default |
|---|
| 840 |
use version 0.9.1 or newer). |
|---|
| 841 |
\layout Enumerate |
|---|
| 842 |
|
|---|
| 843 |
|
|---|
| 844 |
\family typewriter |
|---|
| 845 |
Readline |
|---|
| 846 |
\family default |
|---|
| 847 |
for Windows from |
|---|
| 848 |
\begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools} |
|---|
| 849 |
|
|---|
| 850 |
\end_inset |
|---|
| 851 |
|
|---|
| 852 |
. |
|---|
| 853 |
\layout Standard |
|---|
| 854 |
|
|---|
| 855 |
|
|---|
| 856 |
\series bold |
|---|
| 857 |
Warning about a broken readline-like library: |
|---|
| 858 |
\series default |
|---|
| 859 |
several users have reported problems stemming from using the pseudo-readline |
|---|
| 860 |
library at |
|---|
| 861 |
\begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html} |
|---|
| 862 |
|
|---|
| 863 |
\end_inset |
|---|
| 864 |
|
|---|
| 865 |
. |
|---|
| 866 |
This is a broken library which, while called readline, only implements |
|---|
| 867 |
an incomplete subset of the readline API. |
|---|
| 868 |
Since it is still called readline, it fools IPython's detection mechanisms |
|---|
| 869 |
and causes unpredictable crashes later. |
|---|
| 870 |
If you wish to use IPython under Windows, you must NOT use this library, |
|---|
| 871 |
which for all purposes is (at least as of version 1.6) terminally broken. |
|---|
| 872 |
\layout Subsubsection |
|---|
| 873 |
|
|---|
| 874 |
Gary Bishop's readline and color support for Windows |
|---|
| 875 |
\layout Standard |
|---|
| 876 |
|
|---|
| 877 |
Some of IPython's very useful features are: |
|---|
| 878 |
\layout Itemize |
|---|
| 879 |
|
|---|
| 880 |
Integrated readline support (Tab-based file, object and attribute completion, |
|---|
| 881 |
input history across sessions, editable command line, etc.) |
|---|
| 882 |
\layout Itemize |
|---|
| 883 |
|
|---|
| 884 |
Coloring of prompts, code and tracebacks. |
|---|
| 885 |
\layout Standard |
|---|
| 886 |
|
|---|
| 887 |
These, by default, are only available under Unix-like operating systems. |
|---|
| 888 |
However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit |
|---|
| 889 |
from them. |
|---|
| 890 |
His readline library implements both GNU readline functionality and color |
|---|
| 891 |
support, so that IPython under Windows XP/2k can be as friendly and powerful |
|---|
| 892 |
as under Unix-like environments. |
|---|
| 893 |
\layout Standard |
|---|
| 894 |
|
|---|
| 895 |
You can find Gary's tools at |
|---|
| 896 |
\begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools} |
|---|
| 897 |
|
|---|
| 898 |
\end_inset |
|---|
| 899 |
|
|---|
| 900 |
; Gary's |
|---|
| 901 |
\family typewriter |
|---|
| 902 |
readline |
|---|
| 903 |
\family default |
|---|
| 904 |
requires in turn the |
|---|
| 905 |
\family typewriter |
|---|
| 906 |
ctypes |
|---|
| 907 |
\family default |
|---|
| 908 |
library by Thomas Heller, available at |
|---|
| 909 |
\begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes} |
|---|
| 910 |
|
|---|
| 911 |
\end_inset |
|---|
| 912 |
|
|---|
| 913 |
, and Mark Hammond's |
|---|
| 914 |
\family typewriter |
|---|
| 915 |
PyWin32 |
|---|
| 916 |
\family default |
|---|
| 917 |
from |
|---|
| 918 |
\begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond} |
|---|
| 919 |
|
|---|
| 920 |
\end_inset |
|---|
| 921 |
|
|---|
| 922 |
( |
|---|
| 923 |
\family typewriter |
|---|
| 924 |
PyWin32 |
|---|
| 925 |
\family default |
|---|
| 926 |
is great for anything Windows-related anyway, so you might as well get |
|---|
| 927 |
it). |
|---|
| 928 |
\layout Standard |
|---|
| 929 |
|
|---|
| 930 |
Under MS\SpecialChar ~ |
|---|
| 931 |
Windows, IPython will complain if it can not find this |
|---|
| 932 |
\family typewriter |
|---|
| 933 |
readline |
|---|
| 934 |
\family default |
|---|
| 935 |
library at startup and any time the |
|---|
| 936 |
\family typewriter |
|---|
| 937 |
%colors |
|---|
| 938 |
\family default |
|---|
| 939 |
command is issued, so you can consider it to be a quasi-requirement. |
|---|
| 940 |
\layout Subsubsection |
|---|
| 941 |
|
|---|
| 942 |
Installation procedure |
|---|
| 943 |
\layout Standard |
|---|
| 944 |
|
|---|
| 945 |
Once you have the above installed, from the IPython download directory grab |
|---|
| 946 |
the |
|---|
| 947 |
\family typewriter |
|---|
| 948 |
ipython-XXX.win32.exe |
|---|
| 949 |
\family default |
|---|
| 950 |
file, where |
|---|
| 951 |
\family typewriter |
|---|
| 952 |
XXX |
|---|
| 953 |
\family default |
|---|
| 954 |
represents the version number. |
|---|
| 955 |
This is a regular windows executable installer, which you can simply double-cli |
|---|
| 956 |
ck to install. |
|---|
| 957 |
It will add an entry for IPython to your Start Menu, as well as registering |
|---|
| 958 |
IPython in the Windows list of applications, so you can later uninstall |
|---|
| 959 |
it from the Control Panel. |
|---|
| 960 |
|
|---|
| 961 |
\layout Standard |
|---|
| 962 |
|
|---|
| 963 |
IPython tries to install the configuration information in a directory named |
|---|
| 964 |
|
|---|
| 965 |
\family typewriter |
|---|
| 966 |
.ipython |
|---|
| 967 |
\family default |
|---|
| 968 |
( |
|---|
| 969 |
\family typewriter |
|---|
| 970 |
_ipython |
|---|
| 971 |
\family default |
|---|
| 972 |
under Windows) located in your `home' directory. |
|---|
| 973 |
IPython sets this directory by looking for a |
|---|
| 974 |
\family typewriter |
|---|
| 975 |
HOME |
|---|
| 976 |
\family default |
|---|
| 977 |
environment variable; if such a variable does not exist, it uses |
|---|
| 978 |
\family typewriter |
|---|
| 979 |
HOMEDRIVE |
|---|
| 980 |
\backslash |
|---|
| 981 |
HOMEPATH |
|---|
| 982 |
\family default |
|---|
| 983 |
(these are always defined by Windows). |
|---|
| 984 |
This typically gives something like |
|---|
| 985 |
\family typewriter |
|---|
| 986 |
C: |
|---|
| 987 |
\backslash |
|---|
| 988 |
Documents and Settings |
|---|
| 989 |
\backslash |
|---|
| 990 |
YourUserName |
|---|
| 991 |
\family default |
|---|
| 992 |
, but your local details may vary. |
|---|
| 993 |
In this directory you will find all the files that configure IPython's |
|---|
| 994 |
defaults, and you can put there your profiles and extensions. |
|---|
| 995 |
This directory is automatically added by IPython to |
|---|
| 996 |
\family typewriter |
|---|
| 997 |
sys.path |
|---|
| 998 |
\family default |
|---|
| 999 |
, so anything you place there can be found by |
|---|
| 1000 |
\family typewriter |
|---|
| 1001 |
import |
|---|
| 1002 |
\family default |
|---|
| 1003 |
statements. |
|---|
| 1004 |
\layout Paragraph |
|---|
| 1005 |
|
|---|
| 1006 |
Upgrading |
|---|
| 1007 |
\layout Standard |
|---|
| 1008 |
|
|---|
| 1009 |
For an IPython upgrade, you should first uninstall the previous version. |
|---|
| 1010 |
This will ensure that all files and directories (such as the documentation) |
|---|
| 1011 |
which carry embedded version strings in their names are properly removed. |
|---|
| 1012 |
\layout Paragraph |
|---|
| 1013 |
|
|---|
| 1014 |
Manual installation under Win32 |
|---|
| 1015 |
\layout Standard |
|---|
| 1016 |
|
|---|
| 1017 |
In case the automatic installer does not work for some reason, you can download |
|---|
| 1018 |
the |
|---|
| 1019 |
\family typewriter |
|---|
| 1020 |
ipython-XXX.tar.gz |
|---|
| 1021 |
\family default |
|---|
| 1022 |
file, which contains the full IPython source distribution (the popular |
|---|
| 1023 |
WinZip can read |
|---|
| 1024 |
\family typewriter |
|---|
| 1025 |
.tar.gz |
|---|
| 1026 |
\family default |
|---|
| 1027 |
files). |
|---|
| 1028 |
After uncompressing the archive, you can install it at a command terminal |
|---|
| 1029 |
just like any other Python module, by using |
|---|
| 1030 |
\family typewriter |
|---|
| 1031 |
`python setup.py install' |
|---|
| 1032 |
\family default |
|---|
| 1033 |
. |
|---|
| 1034 |
|
|---|
| 1035 |
\layout Standard |
|---|
| 1036 |
|
|---|
| 1037 |
After the installation, run the supplied |
|---|
| 1038 |
\family typewriter |
|---|
| 1039 |
win32_manual_post_install.py |
|---|
| 1040 |
\family default |
|---|
| 1041 |
script, which creates the necessary Start Menu shortcuts for you. |
|---|
| 1042 |
\layout Subsection |
|---|
| 1043 |
|
|---|
| 1044 |
|
|---|
| 1045 |
\begin_inset LatexCommand \label{sec:upgrade} |
|---|
| 1046 |
|
|---|
| 1047 |
\end_inset |
|---|
| 1048 |
|
|---|
| 1049 |
Upgrading from a previous version |
|---|
| 1050 |
\layout Standard |
|---|
| 1051 |
|
|---|
| 1052 |
If you are upgrading from a previous version of IPython, after doing the |
|---|
| 1053 |
routine installation described above, you should call IPython with the |
|---|
| 1054 |
|
|---|
| 1055 |
\family typewriter |
|---|
| 1056 |
-upgrade |
|---|
| 1057 |
\family default |
|---|
| 1058 |
option the first time you run your new copy. |
|---|
| 1059 |
This will automatically update your configuration directory while preserving |
|---|
| 1060 |
copies of your old files. |
|---|
| 1061 |
You can then later merge back any personal customizations you may have |
|---|
| 1062 |
made into the new files. |
|---|
| 1063 |
It is a good idea to do this as there may be new options available in the |
|---|
| 1064 |
new configuration files which you will not have. |
|---|
| 1065 |
\layout Standard |
|---|
| 1066 |
|
|---|
| 1067 |
Under Windows, if you don't know how to call python scripts with arguments |
|---|
| 1068 |
from a command line, simply delete the old config directory and IPython |
|---|
| 1069 |
will make a new one. |
|---|
| 1070 |
Win2k and WinXP users will find it in |
|---|
| 1071 |
\family typewriter |
|---|
| 1072 |
C: |
|---|
| 1073 |
\backslash |
|---|
| 1074 |
Documents and Settings |
|---|
| 1075 |
\backslash |
|---|
| 1076 |
YourUserName |
|---|
| 1077 |
\backslash |
|---|
| 1078 |
.ipython |
|---|
| 1079 |
\family default |
|---|
| 1080 |
, and Win 9x users under |
|---|
| 1081 |
\family typewriter |
|---|
| 1082 |
C: |
|---|
| 1083 |
\backslash |
|---|
| 1084 |
Program Files |
|---|
| 1085 |
\backslash |
|---|
| 1086 |
IPython |
|---|
| 1087 |
\backslash |
|---|
| 1088 |
.ipython. |
|---|
| 1089 |
\layout Section |
|---|
| 1090 |
|
|---|
| 1091 |
|
|---|
| 1092 |
\begin_inset LatexCommand \label{sec:good_config} |
|---|
| 1093 |
|
|---|
| 1094 |
\end_inset |
|---|
| 1095 |
|
|---|
| 1096 |
|
|---|
| 1097 |
\begin_inset OptArg |
|---|
| 1098 |
collapsed true |
|---|
| 1099 |
|
|---|
| 1100 |
\layout Standard |
|---|
| 1101 |
|
|---|
| 1102 |
Initial configuration |
|---|
| 1103 |
\begin_inset ERT |
|---|
| 1104 |
status Collapsed |
|---|
| 1105 |
|
|---|
| 1106 |
\layout Standard |
|---|
| 1107 |
|
|---|
| 1108 |
\backslash |
|---|
| 1109 |
ldots |
|---|
| 1110 |
\end_inset |
|---|
| 1111 |
|
|---|
| 1112 |
|
|---|
| 1113 |
\end_inset |
|---|
| 1114 |
|
|---|
| 1115 |
Initial configuration of your environment |
|---|
| 1116 |
\layout Standard |
|---|
| 1117 |
|
|---|
| 1118 |
This section will help you set various things in your environment for your |
|---|
| 1119 |
IPython sessions to be as efficient as possible. |
|---|
| 1120 |
All of IPython's configuration information, along with several example |
|---|
| 1121 |
files, is stored in a directory named by default |
|---|
| 1122 |
\family typewriter |
|---|
| 1123 |
$HOME/.ipython |
|---|
| 1124 |
\family default |
|---|
| 1125 |
. |
|---|
| 1126 |
You can change this by defining the environment variable |
|---|
| 1127 |
\family typewriter |
|---|
| 1128 |
IPYTHONDIR |
|---|
| 1129 |
\family default |
|---|
| 1130 |
, or at runtime with the command line option |
|---|
| 1131 |
\family typewriter |
|---|
| 1132 |
-ipythondir |
|---|
| 1133 |
\family default |
|---|
| 1134 |
. |
|---|
| 1135 |
\layout Standard |
|---|
| 1136 |
|
|---|
| 1137 |
If all goes well, the first time you run IPython it should automatically |
|---|
| 1138 |
create a user copy of the config directory for you, based on its builtin |
|---|
| 1139 |
defaults. |
|---|
| 1140 |
You can look at the files it creates to learn more about configuring the |
|---|
| 1141 |
system. |
|---|
| 1142 |
The main file you will modify to configure IPython's behavior is called |
|---|
| 1143 |
|
|---|
| 1144 |
\family typewriter |
|---|
| 1145 |
ipythonrc |
|---|
| 1146 |
\family default |
|---|
| 1147 |
(with a |
|---|
| 1148 |
\family typewriter |
|---|
| 1149 |
.ini |
|---|
| 1150 |
\family default |
|---|
| 1151 |
extension under Windows), included for reference in Sec. |
|---|
| 1152 |
|
|---|
| 1153 |
\begin_inset LatexCommand \ref{sec:ipytonrc-sample} |
|---|
| 1154 |
|
|---|
| 1155 |
\end_inset |
|---|
| 1156 |
|
|---|
| 1157 |
. |
|---|
| 1158 |
This file is very commented and has many variables you can change to suit |
|---|
| 1159 |
your taste, you can find more details in Sec. |
|---|
| 1160 |
|
|---|
| 1161 |
\begin_inset LatexCommand \ref{sec:customization} |
|---|
| 1162 |
|
|---|
| 1163 |
\end_inset |
|---|
| 1164 |
|
|---|
| 1165 |
. |
|---|
| 1166 |
Here we discuss the basic things you will want to make sure things are |
|---|
| 1167 |
working properly from the beginning. |
|---|
| 1168 |
\layout Subsection |
|---|
| 1169 |
|
|---|
| 1170 |
|
|---|
| 1171 |
\begin_inset LatexCommand \label{sec:help-access} |
|---|
| 1172 |
|
|---|
| 1173 |
\end_inset |
|---|
| 1174 |
|
|---|
| 1175 |
Access to the Python help system |
|---|
| 1176 |
\layout Standard |
|---|
| 1177 |
|
|---|
| 1178 |
This is true for Python in general (not just for IPython): you should have |
|---|
| 1179 |
an environment variable called |
|---|
| 1180 |
\family typewriter |
|---|
| 1181 |
PYTHONDOCS |
|---|
| 1182 |
\family default |
|---|
| 1183 |
pointing to the directory where your HTML Python documentation lives. |
|---|
| 1184 |
In my system it's |
|---|
| 1185 |
\family typewriter |
|---|
| 1186 |
/usr/share/doc/python-docs-2.3.4/html |
|---|
| 1187 |
\family default |
|---|
| 1188 |
, check your local details or ask your systems administrator. |
|---|
| 1189 |
|
|---|
| 1190 |
\layout Standard |
|---|
| 1191 |
|
|---|
| 1192 |
This is the directory which holds the HTML version of the Python manuals. |
|---|
| 1193 |
Unfortunately it seems that different Linux distributions package these |
|---|
| 1194 |
files differently, so you may have to look around a bit. |
|---|
| 1195 |
Below I show the contents of this directory on my system for reference: |
|---|
| 1196 |
\layout Standard |
|---|
| 1197 |
|
|---|
| 1198 |
|
|---|
| 1199 |
\family typewriter |
|---|
| 1200 |
[html]> ls |
|---|
| 1201 |
\newline |
|---|
| 1202 |
about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/ |
|---|
| 1203 |
about.html api/ doc/ icons/ inst/ mac/ ref/ style.css |
|---|
| 1204 |
\layout Standard |
|---|
| 1205 |
|
|---|
| 1206 |
You should really make sure this variable is correctly set so that Python's |
|---|
| 1207 |
pydoc-based help system works. |
|---|
| 1208 |
It is a powerful and convenient system with full access to the Python manuals |
|---|
| 1209 |
and all modules accessible to you. |
|---|
| 1210 |
\layout Standard |
|---|
| 1211 |
|
|---|
| 1212 |
Under Windows it seems that pydoc finds the documentation automatically, |
|---|
| 1213 |
so no extra setup appears necessary. |
|---|
| 1214 |
\layout Subsection |
|---|
| 1215 |
|
|---|
| 1216 |
Editor |
|---|
| 1217 |
\layout Standard |
|---|
| 1218 |
|
|---|
| 1219 |
The |
|---|
| 1220 |
\family typewriter |
|---|
| 1221 |
%edit |
|---|
| 1222 |
\family default |
|---|
| 1223 |
command (and its alias |
|---|
| 1224 |
\family typewriter |
|---|
| 1225 |
%ed |
|---|
| 1226 |
\family default |
|---|
| 1227 |
) will invoke the editor set in your environment as |
|---|
| 1228 |
\family typewriter |
|---|
| 1229 |
EDITOR |
|---|
| 1230 |
\family default |
|---|
| 1231 |
. |
|---|
| 1232 |
If this variable is not set, it will default to |
|---|
| 1233 |
\family typewriter |
|---|
| 1234 |
vi |
|---|
| 1235 |
\family default |
|---|
| 1236 |
under Linux/Unix and to |
|---|
| 1237 |
\family typewriter |
|---|
| 1238 |
notepad |
|---|
| 1239 |
\family default |
|---|
| 1240 |
under Windows. |
|---|
| 1241 |
You may want to set this variable properly and to a lightweight editor |
|---|
| 1242 |
which doesn't take too long to start (that is, something other than a new |
|---|
| 1243 |
instance of |
|---|
| 1244 |
\family typewriter |
|---|
| 1245 |
Emacs |
|---|
| 1246 |
\family default |
|---|
| 1247 |
). |
|---|
| 1248 |
This way you can edit multi-line code quickly and with the power of a real |
|---|
| 1249 |
editor right inside IPython. |
|---|
| 1250 |
|
|---|
| 1251 |
\layout Standard |
|---|
| 1252 |
|
|---|
| 1253 |
If you are a dedicated |
|---|
| 1254 |
\family typewriter |
|---|
| 1255 |
Emacs |
|---|
| 1256 |
\family default |
|---|
| 1257 |
user, you should set up the |
|---|
| 1258 |
\family typewriter |
|---|
| 1259 |
Emacs |
|---|
| 1260 |
\family default |
|---|
| 1261 |
server so that new requests are handled by the original process. |
|---|
| 1262 |
This means that almost no time is spent in handling the request (assuming |
|---|
| 1263 |
an |
|---|
| 1264 |
\family typewriter |
|---|
| 1265 |
Emacs |
|---|
| 1266 |
\family default |
|---|
| 1267 |
process is already running). |
|---|
| 1268 |
For this to work, you need to set your |
|---|
| 1269 |
\family typewriter |
|---|
| 1270 |
EDITOR |
|---|
| 1271 |
\family default |
|---|
| 1272 |
environment variable to |
|---|
| 1273 |
\family typewriter |
|---|
| 1274 |
'emacsclient' |
|---|
| 1275 |
\family default |
|---|
| 1276 |
. |
|---|
| 1277 |
|
|---|
| 1278 |
\family typewriter |
|---|
| 1279 |
|
|---|
| 1280 |
\family default |
|---|
| 1281 |
The code below, supplied by Francois Pinard, can then be used in your |
|---|
| 1282 |
\family typewriter |
|---|
| 1283 |
.emacs |
|---|
| 1284 |
\family default |
|---|
| 1285 |
file to enable the server: |
|---|
| 1286 |
\layout Standard |
|---|
| 1287 |
|
|---|
| 1288 |
|
|---|
| 1289 |
\family typewriter |
|---|
| 1290 |
(defvar server-buffer-clients) |
|---|
| 1291 |
\newline |
|---|
| 1292 |
(when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm)) |
|---|
| 1293 |
\newline |
|---|
| 1294 |
|
|---|
| 1295 |
\begin_inset ERT |
|---|
| 1296 |
status Collapsed |
|---|
| 1297 |
|
|---|
| 1298 |
\layout Standard |
|---|
| 1299 |
|
|---|
| 1300 |
\backslash |
|---|
| 1301 |
hspace*{0mm} |
|---|
| 1302 |
\end_inset |
|---|
| 1303 |
|
|---|
| 1304 |
\SpecialChar ~ |
|---|
| 1305 |
\SpecialChar ~ |
|---|
| 1306 |
(server-start) |
|---|
| 1307 |
\newline |
|---|
| 1308 |
|
|---|
| 1309 |
\begin_inset ERT |
|---|
| 1310 |
status Collapsed |
|---|
| 1311 |
|
|---|
| 1312 |
\layout Standard |
|---|
| 1313 |
|
|---|
| 1314 |
\backslash |
|---|
| 1315 |
hspace*{0mm} |
|---|
| 1316 |
\end_inset |
|---|
| 1317 |
|
|---|
| 1318 |
\SpecialChar ~ |
|---|
| 1319 |
\SpecialChar ~ |
|---|
| 1320 |
(defun fp-kill-server-with-buffer-routine () |
|---|
| 1321 |
\newline |
|---|
| 1322 |
|
|---|
| 1323 |
\begin_inset ERT |
|---|
| 1324 |
status Collapsed |
|---|
| 1325 |
|
|---|
| 1326 |
\layout Standard |
|---|
| 1327 |
|
|---|
| 1328 |
\backslash |
|---|
| 1329 |
hspace*{0mm} |
|---|
| 1330 |
\end_inset |
|---|
| 1331 |
|
|---|
| 1332 |
\SpecialChar ~ |
|---|
| 1333 |
\SpecialChar ~ |
|---|
| 1334 |
\SpecialChar ~ |
|---|
| 1335 |
\SpecialChar ~ |
|---|
| 1336 |
(and server-buffer-clients (server-done))) |
|---|
| 1337 |
\newline |
|---|
| 1338 |
|
|---|
| 1339 |
\begin_inset ERT |
|---|
| 1340 |
status Collapsed |
|---|
| 1341 |
|
|---|
| 1342 |
\layout Standard |
|---|
| 1343 |
|
|---|
| 1344 |
\backslash |
|---|
| 1345 |
hspace*{0mm} |
|---|
| 1346 |
\end_inset |
|---|
| 1347 |
|
|---|
| 1348 |
\SpecialChar ~ |
|---|
| 1349 |
\SpecialChar ~ |
|---|
| 1350 |
(add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine)) |
|---|
| 1351 |
\layout Standard |
|---|
| 1352 |
|
|---|
| 1353 |
You can also set the value of this editor via the commmand-line option '- |
|---|
| 1354 |
\family typewriter |
|---|
| 1355 |
editor' |
|---|
| 1356 |
\family default |
|---|
| 1357 |
or in your |
|---|
| 1358 |
\family typewriter |
|---|
| 1359 |
ipythonrc |
|---|
| 1360 |
\family default |
|---|
| 1361 |
file. |
|---|
| 1362 |
This is useful if you wish to use specifically for IPython an editor different |
|---|
| 1363 |
from your typical default (and for Windows users who tend to use fewer |
|---|
| 1364 |
environment variables). |
|---|
| 1365 |
\layout Subsection |
|---|
| 1366 |
|
|---|
| 1367 |
Color |
|---|
| 1368 |
\layout Standard |
|---|
| 1369 |
|
|---|
| 1370 |
The default IPython configuration has most bells and whistles turned on |
|---|
| 1371 |
(they're pretty safe). |
|---|
| 1372 |
But there's one that |
|---|
| 1373 |
\emph on |
|---|
| 1374 |
may |
|---|
| 1375 |
\emph default |
|---|
| 1376 |
cause problems on some systems: the use of color on screen for displaying |
|---|
| 1377 |
information. |
|---|
| 1378 |
This is very useful, since IPython can show prompts and exception tracebacks |
|---|
| 1379 |
with various colors, display syntax-highlighted source code, and in general |
|---|
| 1380 |
make it easier to visually parse information. |
|---|
| 1381 |
\layout Standard |
|---|
| 1382 |
|
|---|
| 1383 |
The following terminals seem to handle the color sequences fine: |
|---|
| 1384 |
\layout Itemize |
|---|
| 1385 |
|
|---|
| 1386 |
Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm. |
|---|
| 1387 |
\layout Itemize |
|---|
| 1388 |
|
|---|
| 1389 |
CDE terminal (tested under Solaris). |
|---|
| 1390 |
This one boldfaces light colors. |
|---|
| 1391 |
\layout Itemize |
|---|
| 1392 |
|
|---|
| 1393 |
(X)Emacs buffers. |
|---|
| 1394 |
See sec. |
|---|
| 1395 |
\begin_inset LatexCommand \ref{sec:emacs} |
|---|
| 1396 |
|
|---|
| 1397 |
\end_inset |
|---|
| 1398 |
|
|---|
| 1399 |
for more details on using IPython with (X)Emacs. |
|---|
| 1400 |
\layout Itemize |
|---|
| 1401 |
|
|---|
| 1402 |
A Windows (XP/2k) command prompt |
|---|
| 1403 |
\emph on |
|---|
| 1404 |
with Gary Bishop's support extensions |
|---|
| 1405 |
\emph default |
|---|
| 1406 |
. |
|---|
| 1407 |
Gary's extensions are discussed in Sec.\SpecialChar ~ |
|---|
| 1408 |
|
|---|
| 1409 |
\begin_inset LatexCommand \ref{sub:Under-Windows} |
|---|
| 1410 |
|
|---|
| 1411 |
\end_inset |
|---|
| 1412 |
|
|---|
| 1413 |
. |
|---|
| 1414 |
\layout Itemize |
|---|
| 1415 |
|
|---|
| 1416 |
A Windows (XP/2k) CygWin shell. |
|---|
| 1417 |
Although some users have reported problems; it is not clear whether there |
|---|
| 1418 |
is an issue for everyone or only under specific configurations. |
|---|
| 1419 |
If you have full color support under cygwin, please post to the IPython |
|---|
| 1420 |
mailing list so this issue can be resolved for all users. |
|---|
| 1421 |
\layout Standard |
|---|
| 1422 |
|
|---|
| 1423 |
These have shown problems: |
|---|
| 1424 |
\layout Itemize |
|---|
| 1425 |
|
|---|
| 1426 |
Windows command prompt in WinXP/2k logged into a Linux machine via telnet |
|---|
| 1427 |
or ssh. |
|---|
| 1428 |
\layout Itemize |
|---|
| 1429 |
|
|---|
| 1430 |
Windows native command prompt in WinXP/2k, |
|---|
| 1431 |
\emph on |
|---|
| 1432 |
without |
|---|
| 1433 |
\emph default |
|---|
| 1434 |
Gary Bishop's extensions. |
|---|
| 1435 |
Once Gary's readline library is installed, the normal WinXP/2k command |
|---|
| 1436 |
prompt works perfectly. |
|---|
| 1437 |
\layout Standard |
|---|
| 1438 |
|
|---|
| 1439 |
Currently the following color schemes are available: |
|---|
| 1440 |
\layout Itemize |
|---|
| 1441 |
|
|---|
| 1442 |
|
|---|
| 1443 |
\family typewriter |
|---|
| 1444 |
NoColor |
|---|
| 1445 |
\family default |
|---|
| 1446 |
: uses no color escapes at all (all escapes are empty |
|---|
| 1447 |
\begin_inset Quotes eld |
|---|
| 1448 |
\end_inset |
|---|
| 1449 |
|
|---|
| 1450 |
|
|---|
| 1451 |
\begin_inset Quotes eld |
|---|
| 1452 |
\end_inset |
|---|
| 1453 |
|
|---|
| 1454 |
strings). |
|---|
| 1455 |
This 'scheme' is thus fully safe to use in any terminal. |
|---|
| 1456 |
|---|