##// END OF EJS Templates
major doc update for 1.0 release...
Paul Ivanov -
Show More
@@ -0,0 +1,9 b''
1 <html>
2 <head>
3 <meta http-equiv="Refresh" content="0; url=notebook.html" />
4 <title>Notebook page has move</title>
5 </head>
6 <body>
7 <p>The notebook page has moved to <a href="notebook.html">this link</a>.</p>
8 </body>
9 </html>
@@ -1,235 +1,237 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 #
2 #
3 # IPython documentation build configuration file.
3 # IPython documentation build configuration file.
4
4
5 # NOTE: This file has been edited manually from the auto-generated one from
5 # NOTE: This file has been edited manually from the auto-generated one from
6 # sphinx. Do NOT delete and re-generate. If any changes from sphinx are
6 # sphinx. Do NOT delete and re-generate. If any changes from sphinx are
7 # needed, generate a scratch one and merge by hand any new fields needed.
7 # needed, generate a scratch one and merge by hand any new fields needed.
8
8
9 #
9 #
10 # This file is execfile()d with the current directory set to its containing dir.
10 # This file is execfile()d with the current directory set to its containing dir.
11 #
11 #
12 # The contents of this file are pickled, so don't put values in the namespace
12 # The contents of this file are pickled, so don't put values in the namespace
13 # that aren't pickleable (module imports are okay, they're removed automatically).
13 # that aren't pickleable (module imports are okay, they're removed automatically).
14 #
14 #
15 # All configuration values have a default value; values that are commented out
15 # All configuration values have a default value; values that are commented out
16 # serve to show the default value.
16 # serve to show the default value.
17
17
18 import sys, os
18 import sys, os
19
19
20 ON_RTD = os.environ.get('READTHEDOCS', None) == 'True'
20 ON_RTD = os.environ.get('READTHEDOCS', None) == 'True'
21
21
22 if ON_RTD:
22 if ON_RTD:
23 # Mock the presence of matplotlib, which we don't have on RTD
23 # Mock the presence of matplotlib, which we don't have on RTD
24 # see
24 # see
25 # http://read-the-docs.readthedocs.org/en/latest/faq.html
25 # http://read-the-docs.readthedocs.org/en/latest/faq.html
26 tags.add('rtd')
26 tags.add('rtd')
27
27
28 # If your extensions are in another directory, add it here. If the directory
28 # If your extensions are in another directory, add it here. If the directory
29 # is relative to the documentation root, use os.path.abspath to make it
29 # is relative to the documentation root, use os.path.abspath to make it
30 # absolute, like shown here.
30 # absolute, like shown here.
31 sys.path.insert(0, os.path.abspath('../sphinxext'))
31 sys.path.insert(0, os.path.abspath('../sphinxext'))
32
32
33 # We load the ipython release info into a dict by explicit execution
33 # We load the ipython release info into a dict by explicit execution
34 iprelease = {}
34 iprelease = {}
35 execfile('../../IPython/core/release.py',iprelease)
35 execfile('../../IPython/core/release.py',iprelease)
36
36
37 # General configuration
37 # General configuration
38 # ---------------------
38 # ---------------------
39
39
40 # Add any Sphinx extension module names here, as strings. They can be extensions
40 # Add any Sphinx extension module names here, as strings. They can be extensions
41 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
41 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
42 extensions = [
42 extensions = [
43 'matplotlib.sphinxext.mathmpl',
43 'matplotlib.sphinxext.mathmpl',
44 'matplotlib.sphinxext.only_directives',
44 'matplotlib.sphinxext.only_directives',
45 'matplotlib.sphinxext.plot_directive',
45 'matplotlib.sphinxext.plot_directive',
46 'sphinx.ext.autodoc',
46 'sphinx.ext.autodoc',
47 'sphinx.ext.doctest',
47 'sphinx.ext.doctest',
48 'sphinx.ext.inheritance_diagram',
48 'sphinx.ext.inheritance_diagram',
49 'IPython.sphinxext.ipython_console_highlighting',
49 'IPython.sphinxext.ipython_console_highlighting',
50 'IPython.sphinxext.ipython_directive',
50 'IPython.sphinxext.ipython_directive',
51 'numpydoc', # to preprocess docstrings
51 'numpydoc', # to preprocess docstrings
52 'github', # for easy GitHub links
52 'github', # for easy GitHub links
53 ]
53 ]
54
54
55 if ON_RTD:
55 if ON_RTD:
56 # Remove extensions not currently supported on RTD
56 # Remove extensions not currently supported on RTD
57 extensions.remove('matplotlib.sphinxext.only_directives')
57 extensions.remove('matplotlib.sphinxext.only_directives')
58 extensions.remove('matplotlib.sphinxext.mathmpl')
58 extensions.remove('matplotlib.sphinxext.mathmpl')
59 extensions.remove('matplotlib.sphinxext.plot_directive')
59 extensions.remove('matplotlib.sphinxext.plot_directive')
60 extensions.remove('IPython.sphinxext.ipython_directive')
60 extensions.remove('IPython.sphinxext.ipython_directive')
61 extensions.remove('IPython.sphinxext.ipython_console_highlighting')
61 extensions.remove('IPython.sphinxext.ipython_console_highlighting')
62
62
63 # Add any paths that contain templates here, relative to this directory.
63 # Add any paths that contain templates here, relative to this directory.
64 templates_path = ['_templates']
64 templates_path = ['_templates']
65
65
66 # The suffix of source filenames.
66 # The suffix of source filenames.
67 source_suffix = '.rst'
67 source_suffix = '.rst'
68
68
69 if iprelease['_version_extra']:
69 if iprelease['_version_extra']:
70 rst_prolog = """
70 rst_prolog = """
71 .. note::
71 .. note::
72
72
73 This documentation is for a development version of IPython. There may be
73 This documentation is for a development version of IPython. There may be
74 significant differences from the latest stable release (0.13.2).
74 significant differences from the latest stable release (0.13.2).
75
75
76 """
76 """
77
77
78 # The master toctree document.
78 # The master toctree document.
79 master_doc = 'index'
79 master_doc = 'index'
80
80
81 # General substitutions.
81 # General substitutions.
82 project = 'IPython'
82 project = 'IPython'
83 copyright = '2008, The IPython Development Team'
83 copyright = '2008, The IPython Development Team'
84
84
85 # ghissue config
85 # ghissue config
86 github_project_url = "https://github.com/ipython/ipython"
86 github_project_url = "https://github.com/ipython/ipython"
87
87
88 # The default replacements for |version| and |release|, also used in various
88 # The default replacements for |version| and |release|, also used in various
89 # other places throughout the built documents.
89 # other places throughout the built documents.
90 #
90 #
91 # The full version, including alpha/beta/rc tags.
91 # The full version, including alpha/beta/rc tags.
92 codename = iprelease['codename']
92 codename = iprelease['codename']
93 release = "%s: %s" % (iprelease['version'], codename)
93 release = "%s: %s" % (iprelease['version'], codename)
94 # Just the X.Y.Z part, no '-dev'
94 # Just the X.Y.Z part, no '-dev'
95 version = iprelease['version'].split('-', 1)[0]
95 version = iprelease['version'].split('-', 1)[0]
96
96
97
97
98 # There are two options for replacing |today|: either, you set today to some
98 # There are two options for replacing |today|: either, you set today to some
99 # non-false value, then it is used:
99 # non-false value, then it is used:
100 #today = ''
100 #today = ''
101 # Else, today_fmt is used as the format for a strftime call.
101 # Else, today_fmt is used as the format for a strftime call.
102 today_fmt = '%B %d, %Y'
102 today_fmt = '%B %d, %Y'
103
103
104 # List of documents that shouldn't be included in the build.
104 # List of documents that shouldn't be included in the build.
105 #unused_docs = []
105 #unused_docs = []
106
106
107 # List of directories, relative to source directories, that shouldn't be searched
107 # List of directories, relative to source directories, that shouldn't be searched
108 # for source files.
108 # for source files.
109 exclude_dirs = ['attic']
109 exclude_dirs = ['attic']
110
110
111 # If true, '()' will be appended to :func: etc. cross-reference text.
111 # If true, '()' will be appended to :func: etc. cross-reference text.
112 #add_function_parentheses = True
112 #add_function_parentheses = True
113
113
114 # If true, the current module name will be prepended to all description
114 # If true, the current module name will be prepended to all description
115 # unit titles (such as .. function::).
115 # unit titles (such as .. function::).
116 #add_module_names = True
116 #add_module_names = True
117
117
118 # If true, sectionauthor and moduleauthor directives will be shown in the
118 # If true, sectionauthor and moduleauthor directives will be shown in the
119 # output. They are ignored by default.
119 # output. They are ignored by default.
120 #show_authors = False
120 #show_authors = False
121
121
122 # The name of the Pygments (syntax highlighting) style to use.
122 # The name of the Pygments (syntax highlighting) style to use.
123 pygments_style = 'sphinx'
123 pygments_style = 'sphinx'
124
124
125
125
126 # Options for HTML output
126 # Options for HTML output
127 # -----------------------
127 # -----------------------
128
128
129 # The style sheet to use for HTML and HTML Help pages. A file of that name
129 # The style sheet to use for HTML and HTML Help pages. A file of that name
130 # must exist either in Sphinx' static/ path, or in one of the custom paths
130 # must exist either in Sphinx' static/ path, or in one of the custom paths
131 # given in html_static_path.
131 # given in html_static_path.
132 html_style = 'default.css'
132 html_style = 'default.css'
133
133
134 # The name for this set of Sphinx documents. If None, it defaults to
134 # The name for this set of Sphinx documents. If None, it defaults to
135 # "<project> v<release> documentation".
135 # "<project> v<release> documentation".
136 #html_title = None
136 #html_title = None
137
137
138 # The name of an image file (within the static path) to place at the top of
138 # The name of an image file (within the static path) to place at the top of
139 # the sidebar.
139 # the sidebar.
140 #html_logo = None
140 #html_logo = None
141
141
142 # Add any paths that contain custom static files (such as style sheets) here,
142 # Add any paths that contain custom static files (such as style sheets) here,
143 # relative to this directory. They are copied after the builtin static files,
143 # relative to this directory. They are copied after the builtin static files,
144 # so a file named "default.css" will overwrite the builtin "default.css".
144 # so a file named "default.css" will overwrite the builtin "default.css".
145 html_static_path = ['_static']
145 html_static_path = ['_static']
146
146
147 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
147 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
148 # using the given strftime format.
148 # using the given strftime format.
149 html_last_updated_fmt = '%b %d, %Y'
149 html_last_updated_fmt = '%b %d, %Y'
150
150
151 # If true, SmartyPants will be used to convert quotes and dashes to
151 # If true, SmartyPants will be used to convert quotes and dashes to
152 # typographically correct entities.
152 # typographically correct entities.
153 #html_use_smartypants = True
153 #html_use_smartypants = True
154
154
155 # Custom sidebar templates, maps document names to template names.
155 # Custom sidebar templates, maps document names to template names.
156 #html_sidebars = {}
156 #html_sidebars = {}
157
157
158 # Additional templates that should be rendered to pages, maps page names to
158 # Additional templates that should be rendered to pages, maps page names to
159 # template names.
159 # template names.
160 #html_additional_pages = {}
160 html_additional_pages = {
161 'interactive/htmlnotebook': 'htmlnotebook.html',
162 }
161
163
162 # If false, no module index is generated.
164 # If false, no module index is generated.
163 #html_use_modindex = True
165 #html_use_modindex = True
164
166
165 # If true, the reST sources are included in the HTML build as _sources/<name>.
167 # If true, the reST sources are included in the HTML build as _sources/<name>.
166 #html_copy_source = True
168 #html_copy_source = True
167
169
168 # If true, an OpenSearch description file will be output, and all pages will
170 # If true, an OpenSearch description file will be output, and all pages will
169 # contain a <link> tag referring to it. The value of this option must be the
171 # contain a <link> tag referring to it. The value of this option must be the
170 # base URL from which the finished HTML is served.
172 # base URL from which the finished HTML is served.
171 #html_use_opensearch = ''
173 #html_use_opensearch = ''
172
174
173 # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
175 # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
174 #html_file_suffix = ''
176 #html_file_suffix = ''
175
177
176 # Output file base name for HTML help builder.
178 # Output file base name for HTML help builder.
177 htmlhelp_basename = 'ipythondoc'
179 htmlhelp_basename = 'ipythondoc'
178
180
179
181
180 # Options for LaTeX output
182 # Options for LaTeX output
181 # ------------------------
183 # ------------------------
182
184
183 # The paper size ('letter' or 'a4').
185 # The paper size ('letter' or 'a4').
184 latex_paper_size = 'letter'
186 latex_paper_size = 'letter'
185
187
186 # The font size ('10pt', '11pt' or '12pt').
188 # The font size ('10pt', '11pt' or '12pt').
187 latex_font_size = '11pt'
189 latex_font_size = '11pt'
188
190
189 # Grouping the document tree into LaTeX files. List of tuples
191 # Grouping the document tree into LaTeX files. List of tuples
190 # (source start file, target name, title, author, document class [howto/manual]).
192 # (source start file, target name, title, author, document class [howto/manual]).
191
193
192 latex_documents = [
194 latex_documents = [
193 ('index', 'ipython.tex', 'IPython Documentation',
195 ('index', 'ipython.tex', 'IPython Documentation',
194 ur"""The IPython Development Team""", 'manual', True),
196 ur"""The IPython Development Team""", 'manual', True),
195 ('parallel/winhpc_index', 'winhpc_whitepaper.tex',
197 ('parallel/winhpc_index', 'winhpc_whitepaper.tex',
196 'Using IPython on Windows HPC Server 2008',
198 'Using IPython on Windows HPC Server 2008',
197 ur"Brian E. Granger", 'manual', True)
199 ur"Brian E. Granger", 'manual', True)
198 ]
200 ]
199
201
200 # The name of an image file (relative to this directory) to place at the top of
202 # The name of an image file (relative to this directory) to place at the top of
201 # the title page.
203 # the title page.
202 #latex_logo = None
204 #latex_logo = None
203
205
204 # For "manual" documents, if this is true, then toplevel headings are parts,
206 # For "manual" documents, if this is true, then toplevel headings are parts,
205 # not chapters.
207 # not chapters.
206 #latex_use_parts = False
208 #latex_use_parts = False
207
209
208 # Additional stuff for the LaTeX preamble.
210 # Additional stuff for the LaTeX preamble.
209 #latex_preamble = ''
211 #latex_preamble = ''
210
212
211 # Documents to append as an appendix to all manuals.
213 # Documents to append as an appendix to all manuals.
212 #latex_appendices = []
214 #latex_appendices = []
213
215
214 # If false, no module index is generated.
216 # If false, no module index is generated.
215 latex_use_modindex = True
217 latex_use_modindex = True
216
218
217
219
218 # Options for texinfo output
220 # Options for texinfo output
219 # --------------------------
221 # --------------------------
220
222
221 texinfo_documents = [
223 texinfo_documents = [
222 (master_doc, 'ipython', 'IPython Documentation',
224 (master_doc, 'ipython', 'IPython Documentation',
223 'The IPython Development Team',
225 'The IPython Development Team',
224 'IPython',
226 'IPython',
225 'IPython Documentation',
227 'IPython Documentation',
226 'Programming',
228 'Programming',
227 1),
229 1),
228 ]
230 ]
229
231
230
232
231 # Cleanup
233 # Cleanup
232 # -------
234 # -------
233 # delete release info to avoid pickling errors from sphinx
235 # delete release info to avoid pickling errors from sphinx
234
236
235 del iprelease
237 del iprelease
@@ -1,425 +1,425 b''
1 Overview
1 Overview
2 ========
2 ========
3
3
4 This document describes the steps required to install IPython. IPython is
4 This document describes the steps required to install IPython. IPython is
5 organized into a number of subpackages, each of which has its own dependencies.
5 organized into a number of subpackages, each of which has its own dependencies.
6 All of the subpackages come with IPython, so you don't need to download and
6 All of the subpackages come with IPython, so you don't need to download and
7 install them separately. However, to use a given subpackage, you will need to
7 install them separately. However, to use a given subpackage, you will need to
8 install all of its dependencies.
8 install all of its dependencies.
9
9
10 Please let us know if you have problems installing IPython or any of its
10 Please let us know if you have problems installing IPython or any of its
11 dependencies. Officially, IPython requires Python 2.6, 2.7, 3.1, or 3.2.
11 dependencies. Officially, IPython requires Python 2.6, 2.7, 3.1, or 3.2.
12
12
13 .. warning::
13 .. warning::
14
14
15 Since version 0.11, IPython has a hard syntax dependency on 2.6, and will no
15 Since version 0.11, IPython has a hard syntax dependency on 2.6, and will no
16 longer work on Python <= 2.5. You can find older versions of IPython which
16 longer work on Python <= 2.5. You can find older versions of IPython which
17 supported Python <= 2.5 `here <http://archive.ipython.org/release/>`_
17 supported Python <= 2.5 `here <http://archive.ipython.org/release/>`_
18
18
19 Some of the installation approaches use the :mod:`distribute` package and its
19 Some of the installation approaches use the :mod:`distribute` package and its
20 :command:`easy_install` command line program. In many scenarios, this provides
20 :command:`easy_install` command line program. In many scenarios, this provides
21 the most simple method of installing IPython and its dependencies. More
21 the most simple method of installing IPython and its dependencies. More
22 information about :mod:`distribute` can be found on `its PyPI page
22 information about :mod:`distribute` can be found on `its PyPI page
23 <http://pypi.python.org/pypi/distribute>`__.
23 <http://pypi.python.org/pypi/distribute>`__.
24
24
25 .. note::
25 .. note::
26
26
27 On Windows, IPython has a hard dependency on :mod:`distribute`. We hope to
27 On Windows, IPython has a hard dependency on :mod:`distribute`. We hope to
28 change this in the future, but for now on Windows, you *must* install
28 change this in the future, but for now on Windows, you *must* install
29 :mod:`distribute`.
29 :mod:`distribute`.
30
30
31 More general information about installing Python packages can be found in
31 More general information about installing Python packages can be found in
32 `Python's documentation <http://docs.python.org>`_.
32 `Python's documentation <http://docs.python.org>`_.
33
33
34
34
35 Quickstart
35 Quickstart
36 ==========
36 ==========
37
37
38 If you have :mod:`distribute` installed and you are on OS X or Linux (not
38 If you have :mod:`distribute` installed and you are on OS X or Linux (not
39 Windows), the following will download and install IPython *and* the main
39 Windows), the following will download and install IPython *and* the main
40 optional dependencies:
40 optional dependencies:
41
41
42 .. code-block:: bash
42 .. code-block:: bash
43
43
44 $ easy_install ipython[all]
44 $ easy_install ipython[all]
45
45
46 This will get:
46 This will get:
47
47
48 - jinja2, needed for the notebook
48 - jinja2, needed for the notebook
49 - sphinx, needed for nbconvert
49 - sphinx, needed for nbconvert
50 - pyzmq, needed for IPython's parallel computing features, qt console and
50 - pyzmq, needed for IPython's parallel computing features, qt console and
51 notebook.
51 notebook.
52 - pygments, used by nbconvert and the Qt console for syntax highlighting.
52 - pygments, used by nbconvert and the Qt console for syntax highlighting.
53 - tornado, needed by the web-based notebook
53 - tornado, needed by the web-based notebook
54 - nose, used by the test suite.
54 - nose, used by the test suite.
55
55
56 To run IPython's test suite, use the :command:`iptest` command:
56 To run IPython's test suite, use the :command:`iptest` command:
57
57
58 .. code-block:: bash
58 .. code-block:: bash
59
59
60 $ iptest
60 $ iptest
61
61
62
62
63 Installing IPython itself
63 Installing IPython itself
64 =========================
64 =========================
65
65
66 Given a properly built Python, the basic interactive IPython shell will work
66 Given a properly built Python, the basic interactive IPython shell will work
67 with no external dependencies. However, some Python distributions
67 with no external dependencies. However, some Python distributions
68 (particularly on Windows and OS X), don't come with a working :mod:`readline`
68 (particularly on Windows and OS X), don't come with a working :mod:`readline`
69 module. The IPython shell will work without :mod:`readline`, but will lack
69 module. The IPython shell will work without :mod:`readline`, but will lack
70 many features that users depend on, such as tab completion and command line
70 many features that users depend on, such as tab completion and command line
71 editing. If you install IPython with :mod:`distribute`, (e.g. with
71 editing. If you install IPython with :mod:`distribute`, (e.g. with
72 `easy_install`), then the appropriate :mod:`readline` for your platform will be
72 `easy_install`), then the appropriate :mod:`readline` for your platform will be
73 installed. See below for details of how to make sure you have a working
73 installed. See below for details of how to make sure you have a working
74 :mod:`readline`.
74 :mod:`readline`.
75
75
76 Installation using easy_install
76 Installation using easy_install
77 -------------------------------
77 -------------------------------
78
78
79 If you have :mod:`distribute` installed, the easiest way of getting IPython is
79 If you have :mod:`distribute` installed, the easiest way of getting IPython is
80 to simply use :command:`easy_install`:
80 to simply use :command:`easy_install`:
81
81
82 .. code-block:: bash
82 .. code-block:: bash
83
83
84 $ easy_install ipython
84 $ easy_install ipython
85
85
86 That's it.
86 That's it.
87
87
88 Installation from source
88 Installation from source
89 ------------------------
89 ------------------------
90
90
91 If you don't want to use :command:`easy_install`, or don't have it installed,
91 If you don't want to use :command:`easy_install`, or don't have it installed,
92 just grab the latest stable build of IPython from `here
92 just grab the latest stable build of IPython from `here
93 <http://ipython.org/download.html>`_. Then do the following:
93 <http://ipython.org/download.html>`_. Then do the following:
94
94
95 .. code-block:: bash
95 .. code-block:: bash
96
96
97 $ tar -xzf ipython.tar.gz
97 $ tar -xzf ipython.tar.gz
98 $ cd ipython
98 $ cd ipython
99 $ python setup.py install
99 $ python setup.py install
100
100
101 If you are installing to a location (like ``/usr/local``) that requires higher
101 If you are installing to a location (like ``/usr/local``) that requires higher
102 permissions, you may need to run the last command with :command:`sudo`.
102 permissions, you may need to run the last command with :command:`sudo`.
103
103
104 Windows
104 Windows
105 -------
105 -------
106
106
107 As mentioned above, on Windows, IPython requires :mod:`distribute`, and it also
107 As mentioned above, on Windows, IPython requires :mod:`distribute`, and it also
108 requires the PyReadline library to properly support coloring and keyboard
108 requires the PyReadline library to properly support coloring and keyboard
109 management (features that the default windows console doesn't have). So on
109 management (features that the default windows console doesn't have). So on
110 Windows, the installation procedure is:
110 Windows, the installation procedure is:
111
111
112 1. Install `distribute <http://pypi.python.org/pypi/distribute>`_.
112 1. Install `distribute <http://pypi.python.org/pypi/distribute>`_.
113
113
114 2. Install `pyreadline <http://pypi.python.org/pypi/pyreadline>`_. You can use
114 2. Install `pyreadline <http://pypi.python.org/pypi/pyreadline>`_. You can use
115 the command ``easy_install pyreadline`` from a terminal, or the binary
115 the command ``easy_install pyreadline`` from a terminal, or the binary
116 installer appropriate for your platform from the PyPI page.
116 installer appropriate for your platform from the PyPI page.
117
117
118 3. Install IPython itself, which you can download from `PyPI
118 3. Install IPython itself, which you can download from `PyPI
119 <http://pypi.python.org/pypi/ipython>`_ or from `our site
119 <http://pypi.python.org/pypi/ipython>`_ or from `our site
120 <http://ipython.org/download.html>`_. Note that on Windows 7, you *must*
120 <http://ipython.org/download.html>`_. Note that on Windows 7, you *must*
121 right-click and 'Run as administrator' for the Start menu shortcuts to be
121 right-click and 'Run as administrator' for the Start menu shortcuts to be
122 created.
122 created.
123
123
124 IPython by default runs in a terminal window, but the normal terminal
124 IPython by default runs in a terminal window, but the normal terminal
125 application supplied by Microsoft Windows is very primitive. You may want to
125 application supplied by Microsoft Windows is very primitive. You may want to
126 download the excellent and free Console_ application instead, which is a far
126 download the excellent and free Console_ application instead, which is a far
127 superior tool. You can even configure Console to give you by default an
127 superior tool. You can even configure Console to give you by default an
128 IPython tab, which is very convenient to create new IPython sessions directly
128 IPython tab, which is very convenient to create new IPython sessions directly
129 from the working terminal.
129 from the working terminal.
130
130
131 .. _Console: http://sourceforge.net/projects/console
131 .. _Console: http://sourceforge.net/projects/console
132
132
133
133
134 Installing the development version
134 Installing the development version
135 ----------------------------------
135 ----------------------------------
136
136
137 It is also possible to install the development version of IPython from our
137 It is also possible to install the development version of IPython from our
138 `Git <http://git-scm.com/>`_ source code repository. To do this you will
138 `Git <http://git-scm.com/>`_ source code repository. To do this you will
139 need to have Git installed on your system. Then just do:
139 need to have Git installed on your system. Then just do:
140
140
141 .. code-block:: bash
141 .. code-block:: bash
142
142
143 $ git clone https://github.com/ipython/ipython.git
143 $ git clone https://github.com/ipython/ipython.git
144 $ cd ipython
144 $ cd ipython
145 $ python setup.py install
145 $ python setup.py install
146
146
147 Some users want to be able to follow the development branch as it changes. If
147 Some users want to be able to follow the development branch as it changes. If
148 you have :mod:`distribute` installed, this is easy. Simply replace the last
148 you have :mod:`distribute` installed, this is easy. Simply replace the last
149 step by:
149 step by:
150
150
151 .. code-block:: bash
151 .. code-block:: bash
152
152
153 $ python setupegg.py develop
153 $ python setupegg.py develop
154
154
155 This creates links in the right places and installs the command line script to
155 This creates links in the right places and installs the command line script to
156 the appropriate places. Then, if you want to update your IPython at any time,
156 the appropriate places. Then, if you want to update your IPython at any time,
157 just do:
157 just do:
158
158
159 .. code-block:: bash
159 .. code-block:: bash
160
160
161 $ git pull
161 $ git pull
162
162
163
163
164 Basic optional dependencies
164 Basic optional dependencies
165 ===========================
165 ===========================
166
166
167 There are a number of basic optional dependencies that most users will want to
167 There are a number of basic optional dependencies that most users will want to
168 get. These are:
168 get. These are:
169
169
170 * readline (for command line editing, tab completion, etc.)
170 * readline (for command line editing, tab completion, etc.)
171 * nose (to run the IPython test suite)
171 * nose (to run the IPython test suite)
172 * pexpect (to use things like irunner)
172 * pexpect (to use things like irunner)
173
173
174 If you are comfortable installing these things yourself, have at it, otherwise
174 If you are comfortable installing these things yourself, have at it, otherwise
175 read on for more details.
175 read on for more details.
176
176
177 readline
177 readline
178 --------
178 --------
179
179
180 As indicated above, on Windows, PyReadline is a *mandatory* dependency.
180 As indicated above, on Windows, PyReadline is a *mandatory* dependency.
181 PyReadline is a separate, Windows only implementation of readline that uses
181 PyReadline is a separate, Windows only implementation of readline that uses
182 native Windows calls through :mod:`ctypes`. The easiest way of installing
182 native Windows calls through :mod:`ctypes`. The easiest way of installing
183 PyReadline is you use the binary installer available `here
183 PyReadline is you use the binary installer available `here
184 <http://pypi.python.org/pypi/pyreadline>`_.
184 <http://pypi.python.org/pypi/pyreadline>`_.
185
185
186 On OSX, if you are using the built-in Python shipped by Apple, you will be
186 On OSX, if you are using the built-in Python shipped by Apple, you will be
187 missing a full readline implementation as Apple ships instead a library called
187 missing a full readline implementation as Apple ships instead a library called
188 ``libedit`` that provides only some of readline's functionality. While you may
188 ``libedit`` that provides only some of readline's functionality. While you may
189 find libedit sufficient, we have occasional reports of bugs with it and several
189 find libedit sufficient, we have occasional reports of bugs with it and several
190 developers who use OS X as their main environment consider libedit unacceptable
190 developers who use OS X as their main environment consider libedit unacceptable
191 for productive, regular use with IPython.
191 for productive, regular use with IPython.
192
192
193 Therefore, we *strongly* recommend that on OS X you get the full
193 Therefore, we *strongly* recommend that on OS X you get the full
194 :mod:`readline` module. We will *not* consider completion/history problems to
194 :mod:`readline` module. We will *not* consider completion/history problems to
195 be bugs for IPython if you are using libedit.
195 be bugs for IPython if you are using libedit.
196
196
197 To get a working :mod:`readline` module, just do (with :mod:`distribute`
197 To get a working :mod:`readline` module, just do (with :mod:`distribute`
198 installed):
198 installed):
199
199
200 .. code-block:: bash
200 .. code-block:: bash
201
201
202 $ easy_install readline
202 $ easy_install readline
203
203
204 .. note::
204 .. note::
205
205
206 Other Python distributions on OS X (such as fink, MacPorts and the official
206 Other Python distributions on OS X (such as fink, MacPorts and the official
207 python.org binaries) already have readline installed so you likely don't
207 python.org binaries) already have readline installed so you likely don't
208 have to do this step.
208 have to do this step.
209
209
210 When IPython is installed with :mod:`distribute`, (e.g. using the
210 When IPython is installed with :mod:`distribute`, (e.g. using the
211 ``easy_install`` command), readline is added as a dependency on OS X, and
211 ``easy_install`` command), readline is added as a dependency on OS X, and
212 PyReadline on Windows, and will be installed on your system. However, if you
212 PyReadline on Windows, and will be installed on your system. However, if you
213 do not use distribute, you may have to install one of these packages yourself.
213 do not use distribute, you may have to install one of these packages yourself.
214
214
215
215
216 nose
216 nose
217 ----
217 ----
218
218
219 To run the IPython test suite you will need the :mod:`nose` package. Nose
219 To run the IPython test suite you will need the :mod:`nose` package. Nose
220 provides a great way of sniffing out and running all of the IPython tests. The
220 provides a great way of sniffing out and running all of the IPython tests. The
221 simplest way of getting nose, is to use :command:`easy_install`:
221 simplest way of getting nose, is to use :command:`easy_install`:
222
222
223 .. code-block:: bash
223 .. code-block:: bash
224
224
225 $ easy_install nose
225 $ easy_install nose
226
226
227 Another way of getting this is to do:
227 Another way of getting this is to do:
228
228
229 .. code-block:: bash
229 .. code-block:: bash
230
230
231 $ easy_install ipython[test]
231 $ easy_install ipython[test]
232
232
233 For more installation options, see the `nose website
233 For more installation options, see the `nose website
234 <http://somethingaboutorange.com/mrl/projects/nose/>`_.
234 <http://somethingaboutorange.com/mrl/projects/nose/>`_.
235
235
236 Once you have nose installed, you can run IPython's test suite using the
236 Once you have nose installed, you can run IPython's test suite using the
237 iptest command:
237 iptest command:
238
238
239 .. code-block:: bash
239 .. code-block:: bash
240
240
241 $ iptest
241 $ iptest
242
242
243 pexpect
243 pexpect
244 -------
244 -------
245
245
246 The pexpect_ package is used in IPython's :command:`irunner` script, as well as
246 The pexpect_ package is used in IPython's :command:`irunner` script, as well as
247 for managing subprocesses. IPython now includes a version of pexpect in
247 for managing subprocesses. IPython now includes a version of pexpect in
248 :mod:`IPython.external`, but if you have installed pexpect, IPython will use
248 :mod:`IPython.external`, but if you have installed pexpect, IPython will use
249 that instead. On Unix platforms (including OS X), just do:
249 that instead. On Unix platforms (including OS X), just do:
250
250
251 .. code-block:: bash
251 .. code-block:: bash
252
252
253 $ easy_install pexpect
253 $ easy_install pexpect
254
254
255 Windows users are out of luck as pexpect does not run there.
255 Windows users are out of luck as pexpect does not run there.
256
256
257 Dependencies for IPython.parallel (parallel computing)
257 Dependencies for IPython.parallel (parallel computing)
258 ======================================================
258 ======================================================
259
259
260 :mod:`IPython.kernel` has been replaced by :mod:`IPython.parallel`,
260 :mod:`IPython.kernel` has been replaced by :mod:`IPython.parallel`,
261 which uses ZeroMQ for all communication.
261 which uses ZeroMQ for all communication.
262
262
263 IPython.parallel provides a nice architecture for parallel computing, with a
263 IPython.parallel provides a nice architecture for parallel computing, with a
264 focus on fluid interactive workflows. These features require just one package:
264 focus on fluid interactive workflows. These features require just one package:
265 PyZMQ. See the next section for PyZMQ details.
265 PyZMQ. See the next section for PyZMQ details.
266
266
267 On a Unix style platform (including OS X), if you want to use
267 On a Unix style platform (including OS X), if you want to use
268 :mod:`distribute`, you can just do:
268 :mod:`distribute`, you can just do:
269
269
270 .. code-block:: bash
270 .. code-block:: bash
271
271
272 $ easy_install ipython[zmq] # will include pyzmq
272 $ easy_install ipython[zmq] # will include pyzmq
273
273
274 Security in IPython.parallel is provided by SSH tunnels. By default, Linux
274 Security in IPython.parallel is provided by SSH tunnels. By default, Linux
275 and OSX clients will use the shell ssh command, but on Windows, we also
275 and OSX clients will use the shell ssh command, but on Windows, we also
276 support tunneling with paramiko_.
276 support tunneling with paramiko_.
277
277
278 Dependencies for IPython.kernel.zmq
278 Dependencies for IPython.kernel.zmq
279 ===================================
279 ===================================
280
280
281 pyzmq
281 pyzmq
282 -----
282 -----
283
283
284 IPython 0.11 introduced some new functionality, including a two-process
284 IPython 0.11 introduced some new functionality, including a two-process
285 execution model using ZeroMQ_ for communication. The Python bindings to ZeroMQ
285 execution model using ZeroMQ_ for communication. The Python bindings to ZeroMQ
286 are found in the PyZMQ_ project, which is easy_install-able once you have
286 are found in the PyZMQ_ project, which is easy_install-able once you have
287 ZeroMQ installed. If you are on Python 2.6 or 2.7 on OSX, or 2.7 on Windows,
287 ZeroMQ installed. If you are on Python 2.6 or 2.7 on OSX, or 2.7 on Windows,
288 pyzmq has eggs that include ZeroMQ itself.
288 pyzmq has eggs that include ZeroMQ itself.
289
289
290 IPython.kernel.zmq depends on pyzmq >= 2.1.4.
290 IPython.kernel.zmq depends on pyzmq >= 2.1.4.
291
291
292 Dependencies for the IPython QT console
292 Dependencies for the IPython QT console
293 =======================================
293 =======================================
294
294
295 pyzmq
295 pyzmq
296 -----
296 -----
297
297
298 Like the :mod:`IPython.parallel` package, the QT Console requires ZeroMQ and
298 Like the :mod:`IPython.parallel` package, the QT Console requires ZeroMQ and
299 PyZMQ.
299 PyZMQ.
300
300
301 Qt
301 Qt
302 --
302 --
303
303
304 Also with 0.11, a new GUI was added using the work in :mod:`IPython.kernel.zmq`, which
304 Also with 0.11, a new GUI was added using the work in :mod:`IPython.kernel.zmq`, which
305 can be launched with ``ipython qtconsole``. The GUI is built on Qt, and works
305 can be launched with ``ipython qtconsole``. The GUI is built on Qt, and works
306 with either PyQt, which can be installed from the `PyQt website
306 with either PyQt, which can be installed from the `PyQt website
307 <http://www.riverbankcomputing.co.uk/>`_, or `PySide
307 <http://www.riverbankcomputing.co.uk/>`_, or `PySide
308 <http://www.pyside.org/>`_, from Nokia.
308 <http://www.pyside.org/>`_, from Nokia.
309
309
310 pygments
310 pygments
311 --------
311 --------
312
312
313 The syntax-highlighting in ``ipython qtconsole`` is done with the pygments_
313 The syntax-highlighting in ``ipython qtconsole`` is done with the pygments_
314 project, which is easy_install-able.
314 project, which is easy_install-able.
315
315
316 .. _installnotebook:
316 .. _installnotebook:
317
317
318 Dependencies for the IPython HTML notebook
318 Dependencies for the IPython HTML notebook
319 ==========================================
319 ==========================================
320
320
321 The IPython notebook is a notebook-style web interface to IPython and can be
321 The IPython notebook is a notebook-style web interface to IPython and can be
322 started withe command ``ipython notebook``.
322 started with the command ``ipython notebook``.
323
323
324 pyzmq
324 pyzmq
325 -----
325 -----
326
326
327 Like the :mod:`IPython.parallel` and :mod:`IPython.frontend.qt.console`
327 Like the :mod:`IPython.parallel` and :mod:`IPython.frontend.qt.console`
328 packages, the HTML notebook requires ZeroMQ and PyZMQ.
328 packages, the HTML notebook requires ZeroMQ and PyZMQ.
329
329
330 Tornado
330 Tornado
331 -------
331 -------
332
332
333 The IPython notebook uses the Tornado_ project for its HTTP server. Tornado 2.1
333 The IPython notebook uses the Tornado_ project for its HTTP server. Tornado 2.1
334 is required, in order to support current versions of browsers, due to an update
334 is required, in order to support current versions of browsers, due to an update
335 to the websocket protocol.
335 to the websocket protocol.
336
336
337 Jinja
337 Jinja
338 -----
338 -----
339
339
340 The IPython notebook uses the Jinja_ templating tool to render HTML pages.
340 The IPython notebook uses the Jinja_ templating tool to render HTML pages.
341
341
342
342
343 MathJax
343 MathJax
344 -------
344 -------
345
345
346 The IPython notebook uses the MathJax_ Javascript library for rendering LaTeX
346 The IPython notebook uses the MathJax_ Javascript library for rendering LaTeX
347 in web browsers. Because MathJax is large, we don't include it with
347 in web browsers. Because MathJax is large, we don't include it with
348 IPython. Normally IPython will load MathJax from a CDN, but if you have a slow
348 IPython. Normally IPython will load MathJax from a CDN, but if you have a slow
349 network connection, or want to use LaTeX without an internet connection at all,
349 network connection, or want to use LaTeX without an internet connection at all,
350 you can install MathJax locally.
350 you can install MathJax locally.
351
351
352 A quick and easy method is to install it from a python session::
352 A quick and easy method is to install it from a python session::
353
353
354 from IPython.external.mathjax import install_mathjax
354 from IPython.external.mathjax import install_mathjax
355 install_mathjax()
355 install_mathjax()
356
356
357 If you need tighter configuration control, you can download your own copy
357 If you need tighter configuration control, you can download your own copy
358 of MathJax from http://www.mathjax.org/download/ - use the MathJax-2.0 link.
358 of MathJax from http://www.mathjax.org/download/ - use the MathJax-2.0 link.
359 When you have the file stored locally, install it with::
359 When you have the file stored locally, install it with::
360
360
361 python -m IPython.external.mathjax /path/to/source/mathjax-MathJax-v2.0-20-g07669ac.zip
361 python -m IPython.external.mathjax /path/to/source/mathjax-MathJax-v2.0-20-g07669ac.zip
362
362
363 For unusual needs, IPython can tell you what directory it wants to find MathJax in::
363 For unusual needs, IPython can tell you what directory it wants to find MathJax in::
364
364
365 python -m IPython.external.mathjax -d /some/other/mathjax
365 python -m IPython.external.mathjax -d /some/other/mathjax
366
366
367 By default Mathjax will be installed in your ipython profile directory, but you
367 By default Mathjax will be installed in your ipython profile directory, but you
368 can make system wide install, please refer to the documentation and helper function
368 can make system wide install, please refer to the documentation and helper function
369 of :mod:`IPython.external.mathjax`
369 of :mod:`IPython.external.mathjax`
370
370
371 Browser Compatibility
371 Browser Compatibility
372 ---------------------
372 ---------------------
373
373
374 The IPython notebook is officially supported on the following browers:
374 The IPython notebook is officially supported on the following browers:
375
375
376 * Chrome β‰₯ 13
376 * Chrome β‰₯ 13
377 * Safari β‰₯ 5
377 * Safari β‰₯ 5
378 * Firefox β‰₯ 6
378 * Firefox β‰₯ 6
379
379
380 The is mainly due to the notebook's usage of WebSockets and the flexible box model.
380 The is mainly due to the notebook's usage of WebSockets and the flexible box model.
381
381
382 The following browsers are unsupported:
382 The following browsers are unsupported:
383
383
384 * Safari < 5
384 * Safari < 5
385 * Firefox < 6
385 * Firefox < 6
386 * Chrome < 13
386 * Chrome < 13
387 * Opera (any): CSS issues, but execution might work
387 * Opera (any): CSS issues, but execution might work
388 * Internet Explorer < 10
388 * Internet Explorer < 10
389
389
390 The following specific combinations are known **NOT** to work:
390 The following specific combinations are known **NOT** to work:
391
391
392 * Safari, IPython 0.12, tornado β‰₯ 2.2.0
392 * Safari, IPython 0.12, tornado β‰₯ 2.2.0
393 * Safari with HTTPS connection to notebook and an untrusted certificate (websockets will fail)
393 * Safari with HTTPS connection to notebook and an untrusted certificate (websockets will fail)
394 * The [diigo Chrome extension](http://help.diigo.com/tools/chrome-extension) seems to interfere with scrolling
394 * The [diigo Chrome extension](http://help.diigo.com/tools/chrome-extension) seems to interfere with scrolling
395
395
396 There are some early reports that the Notebook works on Internet Explorer 10, but we
396 There are some early reports that the Notebook works on Internet Explorer 10, but we
397 expect there will be some CSS issues related to the flexible box model.
397 expect there will be some CSS issues related to the flexible box model.
398
398
399
399
400 Dependencies for nbconvert (converting notebooks to various formats)
400 Dependencies for nbconvert (converting notebooks to various formats)
401 ====================================================================
401 ====================================================================
402
402
403 pandoc
403 pandoc
404 ------
404 ------
405
405
406 The most important dependency of nbconvert is Pandoc_, a document format translation program.
406 The most important dependency of nbconvert is Pandoc_, a document format translation program.
407 This is not a Python package, so it cannot be expressed as a regular IPython dependency with setuptools.
407 This is not a Python package, so it cannot be expressed as a regular IPython dependency with setuptools.
408
408
409 To install pandoc on Linux, you can generally use your package manager::
409 To install pandoc on Linux, you can generally use your package manager::
410
410
411 sudo apt-get install pandoc
411 sudo apt-get install pandoc
412
412
413 On other platforms, you can get pandoc from `their website <http://johnmacfarlane.net/pandoc/installing.html>`_.
413 On other platforms, you can get pandoc from `their website <http://johnmacfarlane.net/pandoc/installing.html>`_.
414
414
415
415
416 .. _ZeroMQ: http://www.zeromq.org
416 .. _ZeroMQ: http://www.zeromq.org
417 .. _PyZMQ: https://github.com/zeromq/pyzmq
417 .. _PyZMQ: https://github.com/zeromq/pyzmq
418 .. _paramiko: https://github.com/robey/paramiko
418 .. _paramiko: https://github.com/robey/paramiko
419 .. _pygments: http://pygments.org
419 .. _pygments: http://pygments.org
420 .. _pexpect: http://www.noah.org/wiki/Pexpect
420 .. _pexpect: http://www.noah.org/wiki/Pexpect
421 .. _Jinja: http://jinja.pocoo.org
421 .. _Jinja: http://jinja.pocoo.org
422 .. _Sphinx: http://sphinx-doc.org
422 .. _Sphinx: http://sphinx-doc.org
423 .. _pandoc: http://johnmacfarlane.net/pandoc
423 .. _pandoc: http://johnmacfarlane.net/pandoc
424 .. _Tornado: http://www.tornadoweb.org
424 .. _Tornado: http://www.tornadoweb.org
425 .. _MathJax: http://www.mathjax.org
425 .. _MathJax: http://www.mathjax.org
@@ -1,17 +1,17 b''
1 ==================================
1 ==================================
2 Using IPython for interactive work
2 Using IPython for interactive work
3 ==================================
3 ==================================
4
4
5 .. toctree::
5 .. toctree::
6 :maxdepth: 2
6 :maxdepth: 2
7
7
8 tutorial
8 tutorial
9 tips
9 tips
10 reference
10 reference
11 shell
11 shell
12 qtconsole
12 qtconsole
13 notebook
13 notebook
14 nbconvert
14 nbconvert
15 working_remotely
15 public_server
16
16
17
17
This diff has been collapsed as it changes many lines, (548 lines changed) Show them Hide them
@@ -1,590 +1,492 b''
1 .. _htmlnotebook:
1 .. _htmlnotebook:
2
2
3 The IPython Notebook
3 The IPython Notebook
4 ====================
4 ====================
5
5
6 The IPython Notebook is part of the IPython package, which aims to provide a
6 Introduction
7 powerful, interactive approach to scientific computation.
7 ------------
8 The IPython Notebook extends the previous text-console-based approach, and the
9 later Qt console, in a qualitatively new diretion, providing a web-based
10 application suitable for capturing the whole scientific computation process.
11
8
12 .. seealso::
9 The notebook extends the console-based approach to interactive computing in
10 a qualitatively new direction, providing a web-based application suitable for
11 capturing the whole computation process: developing, documenting, and
12 executing code, as well as communicating the results. The IPython notebook
13 combines two components:
13
14
14 :ref:`Installation requirements <installnotebook>` for the Notebook.
15 **A web application**: a browser-based tool for interactive authoring of
16 documents which combine explanatory text, mathematics, computations and their
17 rich media output.
15
18
19 **Notebook documents**: a representation of all content visible in the web
20 application, including inputs and outputs of the computations, explanatory
21 text, mathematics, images, and rich media representations of objects.
16
22
17 .. Basic structure
23 .. seealso::
18 .. ---------------
19
24
20 Introduction
25 See the :ref:`installation documentation <installnotebook>` for directions
21 ------------
26 on how to install the notebook and its dependencies.
22
27
23 The IPython Notebook combines two components:
24
28
25 * **The IPython Notebook web application**:
29 Main features of the web application
30 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26
31
27 The *IPython Notebook web app* is a browser-based tool for interactive
32 * In-browser editing for code, with automatic syntax highlighting,
28 authoring of literate computations, in which explanatory text,
33 indentation, and tab completion/introspection.
29 mathematics, computations and rich media output may be combined. Input
30 and output are stored in persistent cells that may be edited in-place.
31
34
32 * **Notebook documents**:
35 * The ability to execute code from the browser, with the results of
36 computations attached to the code which generated them.
33
37
34 *Notebook documents*, or *notebooks*, are plain text documents which
38 * Displaying the result of computation using rich media representations, such
35 record all inputs and outputs of the computations, interspersed with
39 as HTML, LaTeX, PNG, SVG, etc. For example, publication-quality figures
36 text, mathematics and HTML 5 representations of objects, in a literate
40 rendered by the matplotlib_ library, can be included inline.
37 style.
38
41
39 Since the similarity in names can lead to some confusion, in this
42 * In-browser editing for rich text using the Markdown_ markup language, which
40 documentation we will use capitalization of the word "notebook" to
43 can provide commentary for the code, is not limited to plain text.
41 distinguish the Notebook app and notebook documents, thinking of the
42 Notebook app as being a proper noun. We will also always refer to the
43 "Notebook app" when we are referring to the browser-based interface,
44 and usually to "notebook documents", instead of "notebooks", for added
45 precision.
46
44
47 We refer to the current state of the computational process taking place in the
45 * The ability to easily include mathematical notation within markdown cells
48 Notebook app, i.e. the (numbered) sequence of input and output cells, as the
46 using LaTeX, and rendered natively by MathJax_.
49 *notebook space*. Notebook documents provide an *exact*, *one-to-one* record
50 of all the content in the notebook space, as a plain text file in JSON format.
51 The Notebook app automatically saves, at certain intervals, the contents of
52 the notebook space to a notebook document stored on disk, with the same name
53 as the title of the notebook space, and the file extension ``.ipynb``. For
54 this reason, there is no confusion about using the same word "notebook" for
55 both the notebook space and the corresponding notebook document, since they are
56 really one and the same concept (we could say that they are "isomorphic").
57
47
58
48
59 Main features of the IPython Notebook web app
60 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61
49
62 The main features of the IPython Notebook app include:
50 .. _MathJax: http://www.mathjax.org/
63
51
64 * In-browser editing for code, with automatic syntax highlighting and
65 indentation and tab completion/introspection.
66
52
67 * Literate combination of code with rich text using the Markdown_ markup
53 Notebook documents
68 language.
54 ~~~~~~~~~~~~~~~~~~
55 Notebook documents contains the inputs and outputs of a interactive session as
56 well as additional text that accompanies the code but is not meant for
57 execution. In this way, notebook files can serve as a complete computational
58 record of a session, interleaving executable code with explanatory text,
59 mathematics, and rich representations of resulting objects. These documents
60 are internally JSON_ files and are saved with the ``.ipynb`` extension. Since
61 JSON is a plain text format, they can be version-controlled and shared with
62 colleagues.
63
64 .. _JSON: http://en.wikipedia.org/wiki/JSON
69
65
70 * Mathematics is easily included within the Markdown using LaTeX notation, and
66 Notebooks may be exported to a range of static formats, including HTML (for
71 rendered natively by MathJax_.
67 example, for blog posts), reStructeredText, LaTeX, PDF, and slide shows, via
68 the new :ref:`nbconvert <nbconvert>` command.
72
69
73 * Displays rich data representations (e.g. HTML / LaTeX / SVG) as the result
70 Furthermore, any ``.ipynb`` notebook document available from a public
74 of computations.
71 URL can be shared via the `IPython Notebook Viewer <nbviewer>`_ (nbviewer_).
72 This service loads the notebook document from the URL and renders it as a
73 static web page. The results may thus be shared with a colleague, or as a
74 public blog post, without other users needing to install IPython themselves.
75 In effect, nbviewer_ is simply :ref:`nbconvert <nbconvert>` as a web service,
76 so you can do your own static conversions with nbconvert, without relying on
77 nbviewer.
75
78
76 * Publication-quality figures in a range of formats (SVG / PNG), rendered by
77 the matplotlib_ library, may be included inline and exported.
78
79
79
80
80 .. _MathJax: http://www.mathjax.org/
81 .. seealso::
81 .. _matplotlib: http://matplotlib.org/
82 .. _Markdown: http://daringfireball.net/projects/markdown/syntax
83
82
83 :ref:`Details on the notebook JSON file format <notebook_format>`
84
84
85
85 Notebook documents
86 Starting the notebook server
86 ~~~~~~~~~~~~~~~~~~
87 ----------------------------
87
88
88 Notebook document files are simple JSON_ files with the
89 You can start running a notebook server from the command line using the
89 extension ``.ipynb``.
90 following command::
90 Since JSON is just plain text, they can be easily version-controlled and shared with colleagues.
91 The notebook stores a *complete*, *reproducible*, *one-to-one* copy of the state of the
92 computational state as it is inside the Notebook app. All computations
93 carried out, and the corresponding results obtained, can be combined in
94 a literate way, interleaving executable code with rich text, mathematics,
95 and rich representations of objects.
96
91
97 .. _JSON: http://en.wikipedia.org/wiki/JSON
92 ipython notebook
98
93
99 Notebooks may easily be exported to a range of static formats, including
94 This will print some information about the notebook server in your console,
100 HTML (for example, for blog posts), PDF and slide shows,
95 and open a web browser to the URL of the web application (by default,
101 via the new nbconvert_ command.
96 ``http://127.0.0.1:8888``).
102
97
103 Furthermore, any ``.ipynb`` notebook document available from a public
98 The landing page of the IPython notebook web application, the **dashboard**,
104 URL can be shared via the `IPython Notebook Viewer <nbviewer>`_ service.
99 shows the notebooks currently available in the notebook directory (by default,
105 This service loads the notebook document from the URL and renders
100 the directory from which the notebook server was started).
106 it as a static web page. The results may thus be shared with a
107 colleague, or as a public blog post, without other users needing to install
108 IPython themselves. NbViewer is simply nbconvert_ as a simple webservice.
109
101
110 See the :ref:`installation documentation <install_index>` for directions on
102 You can create new notebooks from the dashboard with the ``New Notebook``
111 how to install the notebook and its dependencies.
103 button, or open existing ones by clicking on their name. You can also drag
104 and drop ``.ipynb`` notebooks and standard ``.py`` Python source code files
105 into the notebook list area.
112
106
113 .. _nbconvert: ./nbconvert.html
107 When starting a notebook server from the command line, you can also open a
108 particular notebook directly, bypassing the dashboard, with ``ipython notebook
109 my_notebook.ipynb``. The ``.ipynb`` extension is assumed if no extension is
110 given.
111
112 When you are inside an open notebook, the `File | Open...` menu option will
113 open the dashboard in a new browser tab, to allow you to open another notebook
114 from the notebook directory or to create a new notebook.
114
115
115 .. _nbviewer: http://nbviewer.ipython.org
116
116
117 .. note::
117 .. note::
118
118
119 You can start more than one notebook server at the same time, if you want
119 You can start more than one notebook server at the same time, if you want
120 to work on notebooks in different directories. By default the first
120 to work on notebooks in different directories. By default the first
121 notebook server starts on port 8888, and later notebook servers search for
121 notebook server starts on port 8888, and later notebook servers search for
122 ports near that one. You can also manually specify the port with the
122 ports near that one. You can also manually specify the port with the
123 ``--port`` option.
123 ``--port`` option.
124
125
124
126 Basic workflow in the IPython Notebook web app
125 Creating a new notebook document
127 ----------------------------------------------
126 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128
127
129 Starting up
128 A new notebook may be created at any time, either from the dashboard, or using
130 ~~~~~~~~~~~~
129 the `File | New` menu option from within an active notebook. The new notebook
130 is created within the same directory and will open in a new browser tab. It
131 will also be reflected as a new entry in the notebook list on the dashboard.
131
132
132 You can start running the Notebook web app using the following command::
133
133
134 $ ipython notebook
134 Opening notebooks
135 ~~~~~~~~~~~~~~~~~
136 An open notebook has **exactly one** interactive session connected to an
137 :ref:`IPython kernel <ipythonzmq>`, which will execute code sent by the user
138 and communicate back results. This kernel remains active if the web browser
139 window is closed, and reopening the same notebook from the dashboard will
140 reconnect the web application to the same kernel. In the dashboard, notebooks
141 with an active kernel have a ``Shutdown`` button next to them, whereas
142 notebooks without an active kernel have a ``Delete`` button in its place.
135
143
136 (Here, and in the sequel, the initial ``$`` represents the shell prompt,
144 Other clients may connect to the same underlying IPython kernel.
137 indicating that the command is to be run from the command line in a shell.)
145 The notebook server always prints to the terminal the full details of
146 how to connect to each kernel, with messages such as the following::
138
147
139 The landing page of the IPython Notebook application, the *dashboard*, shows
148 [NotebookApp] Kernel started: 87f7d2c0-13e3-43df-8bb8-1bd37aaf3373
140 the notebooks currently available in the *notebook directory* (By default, the directory
141 from which the notebook was started).
142 You can create new notebooks from the dashboard with the ``New Notebook``
143 button, or open existing ones by clicking on their name.
144 You can also drag and drop ``.ipynb`` notebooks and standard ``.py`` Python
145 source code files into the notebook list area.
146
149
150 This long string is the kernel's ID which is sufficient for getting the
151 information necessary to connect to the kernel. You can also request this
152 connection data by running the ``%connect_info`` :ref:`magic
153 <magics_explained>`. This will print the same ID information as well as the
154 content of the JSON data structure it contains.
147
155
148 You can open an existing notebook directly, without having to go via the
156 You can then, for example, manually start a Qt console connected to the *same*
149 dashboard, with::
157 kernel from the command line, by passing a portion of the ID::
150
158
151 ipython notebook my_notebook
159 $ ipython qtconsole --existing 87f7d2c0
152
160
153 The ``.ipynb`` extension is assumed if no extension is given.
161 Without an ID, ``--existing`` will connect to the most recently
154
162 started kernel. This can also be done by running the ``%qtconsole``
155 The `File | Open...` menu option will open the dashboard in a new browser tab,
163 :ref:`magic <magics_explained>` in the notebook.
156 to allow you to select a current notebook
157 from the notebook directory or to create a new notebook.
158
164
165 .. seealso::
159
166
167 :ref:`ipythonzmq`
160
168
161 Notebook user interface
169 Notebook user interface
162 ~~~~~~~~~~~~~~~~~~~~~~~
170 -----------------------
163
164 When you open a new notebook document in the Notebook, you will be presented
165 with the title associated to the notebook space/document, a *menu bar*, a
166 *toolbar* and an empty *input cell*.
167
171
168 Notebook title
172 When you create a new notebook document, you will be presented with the
169 ^^^^^^^^^^^^^^
173 **notebook name**, a **menu bar**, a **toolbar** and an empty **code
170 The title of the notebook document that is currently being edited is displayed
174 cell**.
171 at the top of the page, next to the ``IP[y]: Notebook`` logo. This title may
172 be edited directly by clicking on it. The title is reflected in the name of
173 the ``.ipynb`` notebook document file that is saved.
174
175
175 Menu bar
176 **notebook name**: The name of the notebook document is displayed at the top
176 ^^^^^^^^
177 of the page, next to the ``IP[y]: Notebook`` logo. This name reflects the name
177 The menu bar presents different options that may be used to manipulate the way
178 of the ``.ipynb`` notebook document file. Clicking on the notebook name
178 the Notebook functions.
179 brings up a dialog which allows you to rename it. Thus, renaming a notebook
180 from "Untitled0" to "My first notebook" in the browser, renames the
181 ``Untitled0.ipynb`` file to ``My first notebook.ipynb``.
179
182
180 Toolbar
183 **menu bar**: The menu bar presents different options that may be used to
181 ^^^^^^^
184 manipulate the way the notebook functions.
182 The tool bar gives a quick way of accessing the most-used operations within
183 the Notebook, by clicking on an icon.
184
185
186 **toolbar**: The tool bar gives a quick way of performing the most-used
187 operations within the notebook, by clicking on an icon.
185
188
186 Creating a new notebook document
189 **code cell**: the default type of cell, read on for an explanation of cells
187 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
188
189 A new notebook space/document may be created at any time, either from the
190 dashboard, or using the `File | New` menu option from within an active
191 notebook. The new notebook is created within the same directory and
192 will open in a new browser tab. It will also be reflected as a new entry in
193 the notebook list on the dashboard.
194
190
195
191
196 Structure of a notebook document
192 Structure of a notebook document
197 --------------------------------
193 --------------------------------
198
194
199 Input cells
195 The notebook consists of a sequence of cells. A cell is a multi-line
200 ~~~~~~~~~~~
196 text input field, and its contents can be executed by using
201 Input cells are at the core of the functionality of the IPython Notebook.
197 :kbd:`Shift-Enter`, or by clicking either the "Play" button the toolbar, or
202 They are regions in the document in which you can enter different types of
198 `Cell | Run` in the menu bar. The execution behavior of a cell is determined
203 text and commands. To *execute* or *run* the *current cell*, i.e. the cell
199 the cell's type. There are four types of cells: **code cells**, **markdown
204 under the cursor, you can use the :kbd:`Shift-Enter` key combination.
200 cells**, **raw cells** and **heading cells**. Every cell starts off
205 This tells the Notebook app to perform the relevant operation for each type of
201 being a **code cell**, but its type can be changed by using a dropdown on the
206 cell (see below), and then to display the resulting output.
202 toolbar (which will be "Code", initially), or via :ref:`keyboard shortcuts
207
203 <keyboard-shortcuts>`.
208 The notebook consists of a sequence of input cells, labelled ``In[n]``, which
209 may be executed in a non-linear way, and outputs ``Out[n]``, where ``n`` is a
210 number which denotes the order in which the cells were executed over the
211 history of the computational process. The contents of all of these cells are
212 accessible as Python variables with the same names, forming a complete record
213 of the history of the computation.
214
215
216
217 Input cell types
218 ~~~~~~~~~~~~~~~~
219 Each IPython input cell has a *cell type*, of which there is a restricted
220 number. The type of a cell may be set by using the cell type dropdown on the
221 toolbar, or via the following keyboard shortcuts:
222
223 * **code**: :kbd:`Ctrl-m y`
224 * **markdown**: :kbd:`Ctrl-m m`
225 * **raw**: :kbd:`Ctrl-m t`
226 * **heading**: :kbd:`Ctrl-m 1` - :kbd:`Ctrl-m 6`
227
228 Upon initial creation, each input cell is by default a code cell.
229
204
230
205
231 Code cells
206 Code cells
232 ^^^^^^^^^^
207 ~~~~~~~~~~
233 A *code input cell* allows you to edit code inline within the cell, with full
208 A *code cell* allows you to edit and write new code, with full syntax
234 syntax highlighting and autocompletion/introspection. By default, the language
209 highlighting and tab completion. By default, the language associated to a code
235 associated to a code cell is Python, but other languages, such as ``julia``
210 cell is Python, but other languages, such as ``Julia`` and ``R``, can be
236 and ``R``, can be handled using magic commands (see below).
211 handled using :ref:`cell magic commands <magics_explained>`.
237
212
238 When a code cell is executed with :kbd:`Shift-Enter`, the code that it
213 When a code cell is executed, code that it contains is sent to the kernel
239 contains is transparently exported and run in that language (with automatic
214 associated with the notebook. The results that are returned from this
240 compiling, etc., if necessary). The result that is returned from this
215 computation are then displayed in the notebook as the cell's *output*. The
241 computation is then displayed in the notebook space as the cell's
216 output is not limited to text, with many other possible forms of output are
242 *output*. If this output is of a textual nature, it is placed into a
217 also possible, including ``matplotlib`` figures and HTML tables (as used, for
243 numbered *output cell*. However, many other possible forms of output are also
218 example, in the ``pandas`` data analysis package). This is known as IPython's
244 possible, including ``matplotlib`` figures and HTML tables (as used, for
245 example, in the ``pandas`` data analyis package). This is known as IPython's
246 *rich display* capability.
219 *rich display* capability.
247
220
221 .. seealso::
222
223 `Basic Output`_ example notebook
224
225 `Rich Display System`_ example notebook
248
226
249 Markdown cells
227 Markdown cells
250 ^^^^^^^^^^^^^^
228 ~~~~~~~~~~~~~~
251 You can document the computational process in a literate way, alternating
229 You can document the computational process in a literate way, alternating
252 descriptive text with code, using *rich text*. In IPython this is accomplished
230 descriptive text with code, using *rich text*. In IPython this is accomplished
253 by marking up text with the Markdown language. The corresponding cells are
231 by marking up text with the Markdown language. The corresponding cells are
254 called *Markdown input cells*. The Markdown language provides a simple way to
232 called *Markdown cells*. The Markdown language provides a simple way to
255 perform this text markup, that is, to specify which parts of the text should
233 perform this text markup, that is, to specify which parts of the text should
256 be emphasized (italics), bold, form lists, etc.
234 be emphasized (italics), bold, form lists, etc.
257
235
258
236
259 When a Markdown input cell is executed, the Markdown code is converted into
237 When a Markdown cell is executed, the Markdown code is converted into
260 the corresponding formatted rich text. This output then *replaces* the
238 the corresponding formatted rich text. Markdown allows arbitrary HTML code for
261 original Markdown input cell, leaving just the visually-significant marked up
239 formatting.
262 rich text. Markdown allows arbitrary HTML code for formatting.
263
240
264 Within Markdown cells, you can also include *mathematics* in a straightforward
241 Within Markdown cells, you can also include *mathematics* in a straightforward
265 way, using standard LaTeX notation: ``$...$`` for inline mathematics and
242 way, using standard LaTeX notation: ``$...$`` for inline mathematics and
266 ``$$...$$`` for displayed mathematics. When the Markdown cell is executed,
243 ``$$...$$`` for displayed mathematics. When the Markdown cell is executed,
267 the LaTeX portions are automatically rendered in the HTML output as equations
244 the LaTeX portions are automatically rendered in the HTML output as equations
268 with high quality typography. This is made possible by MathJax_, which
245 with high quality typography. This is made possible by MathJax_, which
269 supports a `large subset <mathjax_tex>`_ of LaTeX functionality
246 supports a `large subset <mathjax_tex>`_ of LaTeX functionality
270
247
271 .. _mathjax_tex: http://docs.mathjax.org/en/latest/tex.html
248 .. _mathjax_tex: http://docs.mathjax.org/en/latest/tex.html
272
249
273 Standard mathematics environments defined by LaTeX and AMS-LaTeX (the
250 Standard mathematics environments defined by LaTeX and AMS-LaTeX (the
274 `amsmath` package) also work, such as
251 `amsmath` package) also work, such as
275 ``\begin{equation}...\end{equation}``, and ``\begin{align}...\end{align}``.
252 ``\begin{equation}...\end{equation}``, and ``\begin{align}...\end{align}``.
276 New LaTeX macros may be defined using standard methods,
253 New LaTeX macros may be defined using standard methods,
277 such as ``\newcommand``, by placing them anywhere *between math delimiters* in
254 such as ``\newcommand``, by placing them anywhere *between math delimiters* in
278 a Markdown cell. These definitions are then available throughout the rest of
255 a Markdown cell. These definitions are then available throughout the rest of
279 the IPython session. (Note, however, that more care must be taken when using
256 the IPython session.
280 nbconvert_ to output to LaTeX).
257
258 .. seealso::
281
259
282 Raw input cells
260 `Markdown Cells`_ example notebook
283 ~~~~~~~~~~~~~~~
284
261
285 *Raw* input cells provide a place in which you can write *output* directly.
262 Raw cells
286 Raw cells are not evaluated by the Notebook, and have no output.
263 ~~~~~~~~~
287 When passed through nbconvert, Raw cells arrive in the destination format unmodified,
264
288 allowing you to type full latex into a raw cell, which will only be rendered
265 *Raw* cells provide a place in which you can write *output* directly.
289 by latex after conversion by nbconvert.
266 Raw cells are not evaluated by the notebook.
267 When passed through :ref:`nbconvert <nbconvert>`, raw cells arrive in the
268 destination format unmodified. For example, this allows you to type full LaTeX
269 into a raw cell, which will only be rendered by LaTeX after conversion by
270 nbconvert.
290
271
291 Heading cells
272 Heading cells
292 ~~~~~~~~~~~~~
273 ~~~~~~~~~~~~~
293
274
294 You can provide a conceptual structure for your computational document as a
275 You can provide a conceptual structure for your computational document as a
295 whole using different levels of headings; there are 6 levels available, from
276 whole using different levels of headings; there are 6 levels available, from
296 level 1 (top level) down to level 6 (paragraph). These can be used later for
277 level 1 (top level) down to level 6 (paragraph). These can be used later for
297 constructing tables of contents, etc.
278 constructing tables of contents, etc. As with Markdown cells, a heading
298
279 cell is replaced by a rich text rendering of the heading when the cell is
299 As with Markdown cells, a heading input cell is replaced by a rich text
280 executed.
300 rendering of the heading when the cell is executed.
301
281
302
282
303 Basic workflow
283 Basic workflow
304 --------------
284 --------------
305
285
306 The normal workflow in a notebook is, then, quite similar to a standard
286 The normal workflow in a notebook is, then, quite similar to a standard
307 IPython session, with the difference that you can edit cells in-place multiple
287 IPython session, with the difference that you can edit cells in-place multiple
308 times until you obtain the desired results, rather than having to
288 times until you obtain the desired results, rather than having to
309 rerun separate scripts with the ``%run`` magic command. (Magic commands do,
289 rerun separate scripts with the ``%run`` magic command.
310 however, also work in the notebook; see below).
290
311
291
312 Typically, you will work on a computational problem in pieces, organizing
292 Typically, you will work on a computational problem in pieces, organizing
313 related ideas into cells and moving forward once previous parts work
293 related ideas into cells and moving forward once previous parts work
314 correctly. This is much more convenient for interactive exploration than
294 correctly. This is much more convenient for interactive exploration than
315 breaking up a computation into scripts that must be executed together, as was
295 breaking up a computation into scripts that must be executed together, as was
316 previously necessary, especially if parts of them take a long time to run
296 previously necessary, especially if parts of them take a long time to run.
317
297
318 At certain moments, it may be necessary to interrupt a calculation which is
298 At certain moments, it may be necessary to interrupt a calculation which is
319 taking too long to complete. This may be done with the ``Kernel | Interrupt``
299 taking too long to complete. This may be done with the `Kernel | Interrupt`
320 menu option, or the :kbd:``Ctrl-i`` keyboard shortcut.
300 menu option, or the :kbd:`Ctrl-m i` keyboard shortcut.
321 Similarly, it may be necessary or desirable to restart the whole computational
301 Similarly, it may be necessary or desirable to restart the whole computational
322 process, with the ``Kernel | Restart`` menu option or :kbd:``Ctrl-.``
302 process, with the `Kernel | Restart` menu option or :kbd:`Ctrl-m .`
323 shortcut. This gives an equivalent state to loading the notebook document
303 shortcut.
324 afresh.
325
304
326 A notebook may be downloaded in either ``.ipynb`` or raw ``.py`` form from the
305 A notebook may be downloaded in either a ``.ipynb`` or ``.py`` file from the
327 menu option ``File | Download as``. Choosing the ``.py`` option downloads a
306 menu option `File | Download as`. Choosing the ``.py`` option downloads a
328 Python ``.py`` script, in which all output has been removed and the content of
307 Python ``.py`` script, in which all rich output has been removed and the
329 Markdown cells in comment areas. See ref:`below <notebook_format>` for more
308 content of markdown cells have been inserted as comments.
330 details on the notebook format.
331
309
332 .. warning::
310 .. seealso::
333
311
334 While in simple cases you can "roundtrip" a notebook to Python, edit the
312 `Running Code in the IPython Notebook`_ example notebook
335 Python file, and then import it back without loss of main content, this is
313
336 in general *not guaranteed to work*. First, there is extra metadata
314 `Basic Output`_ example notebook
337 saved in the notebook that may not be saved to the ``.py`` format. And as
338 the notebook format evolves in complexity, there will be attributes of the
339 notebook that will not survive a roundtrip through the Python form. You
340 should think of the Python format as a way to output a script version of a
341 notebook and the import capabilities as a way to load existing code to get
342 a notebook started. But the Python version is *not* an alternate notebook
343 format.
344
315
316 :ref:`a warning about doing "roundtrip" conversions <note_about_roundtrip>`.
317
318 .. _keyboard-shortcuts:
345
319
346 Keyboard shortcuts
320 Keyboard shortcuts
347 ~~~~~~~~~~~~~~~~~~
321 ~~~~~~~~~~~~~~~~~~
348 All actions in the notebook can be performed with the mouse, but keyboard
322 All actions in the notebook can be performed with the mouse, but keyboard
349 shortcuts are also available for the most common ones. The essential shortcuts
323 shortcuts are also available for the most common ones. The essential shortcuts
350 to remember are the following:
324 to remember are the following:
351
325
352 * :kbd:`Shift-Enter`: run cell
326 * :kbd:`Shift-Enter`: run cell
353 Execute the current cell, show output (if any), and jump to the next cell
327 Execute the current cell, show output (if any), and jump to the next cell
354 below. If :kbd:`Shift-Enter` is invoked on the last input cell, a new code
328 below. If :kbd:`Shift-Enter` is invoked on the last cell, a new code
355 cell will also be created. Note that in the notebook, typing :kbd:`Enter`
329 cell will also be created. Note that in the notebook, typing :kbd:`Enter`
356 on its own *never* forces execution, but rather just inserts a new line in
330 on its own *never* forces execution, but rather just inserts a new line in
357 the current input cell. :kbd:`Shift-Enter` is equivalent to clicking the
331 the current cell. :kbd:`Shift-Enter` is equivalent to clicking the
358 ``Cell | Run`` menu item.
332 ``Cell | Run`` menu item.
359
333
360 * :kbd:`Ctrl-Enter`: run cell in-place
334 * :kbd:`Ctrl-Enter`: run cell in-place
361 Execute the current cell as if it were in "terminal mode", where any
335 Execute the current cell as if it were in "terminal mode", where any
362 output is shown, but the cursor *remains* in the current cell. The cell's
336 output is shown, but the cursor *remains* in the current cell. The cell's
363 entire contents are selected after execution, so you can just start typing
337 entire contents are selected after execution, so you can just start typing
364 and only the new input will be in the cell. This is convenient for doing
338 and only the new input will be in the cell. This is convenient for doing
365 quick experiments in place, or for querying things like filesystem
339 quick experiments in place, or for querying things like filesystem
366 content, without needing to create additional cells that you may not want
340 content, without needing to create additional cells that you may not want
367 to be saved in the notebook.
341 to be saved in the notebook.
368
342
369 * :kbd:`Alt-Enter`: run cell, insert below
343 * :kbd:`Alt-Enter`: run cell, insert below
370 Executes the current cell, shows the output, and inserts a *new* input
344 Executes the current cell, shows the output, and inserts a *new*
371 cell between the current cell and the cell below (if one exists). This
345 cell between the current cell and the cell below (if one exists). This
372 is thus a shortcut for the sequence :kbd:`Shift-Enter`, :kbd:`Ctrl-m a`.
346 is thus a shortcut for the sequence :kbd:`Shift-Enter`, :kbd:`Ctrl-m a`.
373 (:kbd:`Ctrl-m a` adds a new cell above the current one.)
347 (:kbd:`Ctrl-m a` adds a new cell above the current one.)
374
348
375 * :kbd:`Ctrl-m`:
349 * :kbd:`Ctrl-m`:
376 This is the prefix for *all* other shortcuts, which consist of :kbd:`Ctrl-m`
350 This is the prefix for *all* other shortcuts, which consist of :kbd:`Ctrl-m`
377 followed by a single letter or character. For example, if you type
351 followed by a single letter or character. For example, if you type
378 :kbd:`Ctrl-m h` (that is, the sole letter :kbd:`h` after :kbd:`Ctrl-m`),
352 :kbd:`Ctrl-m h` (that is, the sole letter :kbd:`h` after :kbd:`Ctrl-m`),
379 IPython will show you all the available keyboard shortcuts.
353 IPython will show you all the available keyboard shortcuts.
380
354
381
355
382 ..
356 ..
383 TODO: these live in IPython/html/static/notebook/js/quickhelp.js
357 TODO: these live in IPython/html/static/notebook/js/quickhelp.js
384 They were last updated for IPython 1.0 release, so update them again for
358 They were last updated for IPython 1.0 release, so update them again for
385 future releases.
359 future releases.
386
360
387 Here is the complete set of keyboard shortcuts available:
361 Here is the complete set of keyboard shortcuts available:
388
362
389 ============ ==========================
363 ============ ==========================
390 **Shortcut** **Action**
364 **Shortcut** **Action**
391 ------------ --------------------------
365 ------------ --------------------------
392 Shift-Enter run cell
366 Shift-Enter run cell
393 Ctrl-Enter run cell in-place
367 Ctrl-Enter run cell in-place
394 Alt-Enter run cell, insert below
368 Alt-Enter run cell, insert below
395 Ctrl-m x cut cell
369 Ctrl-m x cut cell
396 Ctrl-m c copy cell
370 Ctrl-m c copy cell
397 Ctrl-m v paste cell
371 Ctrl-m v paste cell
398 Ctrl-m d delete cell
372 Ctrl-m d delete cell
399 Ctrl-m z undo last cell deletion
373 Ctrl-m z undo last cell deletion
400 Ctrl-m - split cell
374 Ctrl-m - split cell
401 Ctrl-m a insert cell above
375 Ctrl-m a insert cell above
402 Ctrl-m b insert cell below
376 Ctrl-m b insert cell below
403 Ctrl-m o toggle output
377 Ctrl-m o toggle output
404 Ctrl-m O toggle output scroll
378 Ctrl-m O toggle output scroll
405 Ctrl-m l toggle line numbers
379 Ctrl-m l toggle line numbers
406 Ctrl-m s save notebook
380 Ctrl-m s save notebook
407 Ctrl-m j move cell down
381 Ctrl-m j move cell down
408 Ctrl-m k move cell up
382 Ctrl-m k move cell up
409 Ctrl-m y code cell
383 Ctrl-m y code cell
410 Ctrl-m m markdown cell
384 Ctrl-m m markdown cell
411 Ctrl-m t raw cell
385 Ctrl-m t raw cell
412 Ctrl-m 1-6 heading 1-6 cell
386 Ctrl-m 1-6 heading 1-6 cell
413 Ctrl-m p select previous
387 Ctrl-m p select previous
414 Ctrl-m n select next
388 Ctrl-m n select next
415 Ctrl-m i interrupt kernel
389 Ctrl-m i interrupt kernel
416 Ctrl-m . restart kernel
390 Ctrl-m . restart kernel
417 Ctrl-m h show keyboard shortcuts
391 Ctrl-m h show keyboard shortcuts
418 ============ ==========================
392 ============ ==========================
419
393
420
394
421
395
422 Magic commands
423 --------------
424 Magic commands, or *magics*, are commands for controlling IPython itself.
425 They all begin with ``%`` and are entered into code input cells; the code
426 cells are executed as usual with :kbd:`Shift-Enter`.
427
428 The magic commands call special functions defined by IPython which manipulate
429 the computational state in certain ways.
430
431 There are two types of magics:
432
433 - **line magics**:
434
435 These begin with a single ``%`` and take as arguments the rest of the
436 *same line* of the code cell. Any other lines of the code cell are
437 treated as if they were part of a standard code cell.
438
439 - **cell magics**:
440
441 These begin with ``%%`` and operate on the *entire* remaining contents
442 of the code cell.
443
444 Line magics
445 ~~~~~~~~~~~
446 Some of the available line magics are the following:
447
448 * ``%load filename``:
449
450 Loads the contents of the file ``filename`` into a new code cell. This
451 can be a URL for a remote file.
452
453 * ``%timeit code``:
454
455 An easy way to time how long the single line of code ``code`` takes to
456 run
457
458 * ``%config``:
459
460 Configuration of the IPython Notebook
461
462 * ``%lsmagic``:
463
464 Provides a list of all available magic commands
465
466 Cell magics
467 ~~~~~~~~~~~
468
469 * ``%%latex``:
470
471 Renders the entire contents of the cell in LaTeX, without needing to use
472 explicit LaTeX delimiters.
473
474 * ``%%bash``:
475
476 The code cell is executed by sending it to be executed by ``bash``. The
477 output of the ``bash`` commands is captured and displayed in the
478 notebook.
479
480 * ``%%file filename``:
481
482 Writes the contents of the cell to the file ``filename``.
483 **Caution**: The file is over-written without warning!
484
485 * ``%%R``:
486
487 Execute the contents of the cell using the R language.
488
489 * ``%%timeit``:
490
491 Version of ``%timeit`` which times the entire block of code in the
492 current code cell.
493
494
495
496 Several of the cell magics provide functionality to manipulate the filesystem
497 of a remote server to which you otherwise do not have access.
498
396
499
397
500 Plotting
398 Plotting
501 --------
399 --------
502 One major feature of the Notebook is the ability to interact with
400 One major feature of the notebook is the ability to display plots that are the
503 plots that are the output of running code cells. IPython is designed to work
401 output of running code cells. IPython is designed to work seamlessly with the
504 seamlessly with the ``matplotlib`` plotting library to provide this
402 matplotlib_ plotting library to provide this functionality.
505 functionality.
506
403
507 To set this up, before any plotting is performed you must execute the
404 To set this up, before any plotting is performed you must execute the
508 ``%matplotlib`` magic command. This performs the necessary behind-the-scenes
405 ``%matplotlib`` :ref:`magic command <magics_explained>`. This performs the
509 setup for IPython to work correctly hand in hand with ``matplotlib``; it does
406 necessary behind-the-scenes setup for IPython to work correctly hand in hand
510 *not*, however, actually execute any Python ``import`` commands, that is, no
407 with ``matplotlib``; it does *not*, however, actually execute any Python
511 names are added to the namespace.
408 ``import`` commands, that is, no names are added to the namespace.
512
409
513 If the ``%matplotlib`` magic is called without an argument, the
410 If the ``%matplotlib`` magic is called without an argument, the
514 output of a plotting command is displayed using the default ``matplotlib``
411 output of a plotting command is displayed using the default ``matplotlib``
515 backend in a separate window. Alternatively, the backend can be explicitly
412 backend in a separate window. Alternatively, the backend can be explicitly
516 requested using, for example::
413 requested using, for example::
517
414
518 %matplotlib gtk
415 %matplotlib gtk
519
416
520 A particularly interesting backend is the ``inline`` backend.
417 A particularly interesting backend, provided by IPython, is the ``inline``
521 This is applicable only for the IPython Notebook and the IPython QtConsole.
418 backend. This is available only for the IPython Notebook and the
522 It can be invoked as follows::
419 :ref:`IPython QtConsole <qtconsole>`. It can be invoked as follows::
523
420
524 %matplotlib inline
421 %matplotlib inline
525
422
526 With this backend, output of plotting commands is displayed *inline* within
423 With this backend, the output of plotting commands is displayed *inline*
527 the notebook format, directly below the input cell that produced it. The
424 within the notebook, directly below the code cell that produced it. The
528 resulting plots will then also be stored in the notebook document. This
425 resulting plots will then also be stored in the notebook document.
529 provides a key part of the functionality for reproducibility_ that the IPython
530 Notebook provides.
531
426
532 .. _reproducibility: https://en.wikipedia.org/wiki/Reproducibility
427 .. seealso::
533
428
429 `Plotting with Matplotlib`_ example notebook
534
430
535
431
536 Configuring the IPython Notebook
432 Configuring the IPython Notebook
537 --------------------------------
433 --------------------------------
538 The IPython Notebook can be run with a variety of command line arguments.
434 The notebook server can be run with a variety of command line arguments.
539 To see a list of available options enter::
435 To see a list of available options enter::
540
436
541 $ ipython notebook --help
437 $ ipython notebook --help
542
438
543 Defaults for these options can also be set by creating a file named
439 Defaults for these options can also be set by creating a file named
544 ``ipython_notebook_config.py`` in your IPython *profile folder*. The profile
440 ``ipython_notebook_config.py`` in your IPython *profile folder*. The profile
545 folder is a subfolder of your IPython directory; to find out where it is
441 folder is a subfolder of your IPython directory; to find out where it is
546 located, run::
442 located, run::
547
443
548 $ ipython locate
444 $ ipython locate
549
445
550 To create a new set of default configuration files, with lots of information
446 To create a new set of default configuration files, with lots of information
551 on available options, use::
447 on available options, use::
552
448
553 $ ipython profile create
449 $ ipython profile create
554
450
555 .. seealso::
451 .. seealso::
556
452
557 :ref:`config_overview`, in particular :ref:`Profiles`.
453 :ref:`config_overview`, in particular :ref:`Profiles`.
454
455 :ref:`notebook_security`
456
457 :ref:`notebook_public_server`
558
458
559
459
560 Importing ``.py`` files
460 Importing ``.py`` files
561 -----------------------
461 -----------------------
562
462
563 ``.py`` files will be imported into the IPython Notebook as a notebook with
463 ``.py`` files will be imported as a notebook with
564 the same basename, but an ``.ipynb`` extension, located in the notebook
464 the same basename, but an ``.ipynb`` extension, located in the notebook
565 directory. The notebook created will have just one cell, which will contain
465 directory. The notebook created will have just one cell, which will contain
566 all the code in the ``.py`` file. You can later manually partition this into
466 all the code in the ``.py`` file. You can later manually partition this into
567 individual cells using the ``Edit | Split Cell`` menu option, or the
467 individual cells using the ``Edit | Split Cell`` menu option, or the
568 :kbd:`Ctrl-m -` keyboard shortcut.
468 :kbd:`Ctrl-m -` keyboard shortcut.
569
469
570 Note that ``.py`` scripts obtained from a notebook document using nbconvert_
470 Note that ``.py`` scripts obtained from a notebook document using nbconvert_
571 maintain the structure of the notebook in comments. Reimporting such a
471 maintain the structure of the notebook in comments. Reimporting such a
572 script back into the Notebook will preserve this structxure.
472 script back into a notebook will preserve this structure.
573
473
474 .. _note_about_roundtrip:
574
475
575 .. warning::
476 .. warning::
576
477
577 You can "roundtrip" a notebook to Python, by exporting the
478 While in simple cases you can "roundtrip" a notebook to Python, edit the
578 notebook to a ``.py`` script, editing the script, and then importing it back
479 Python file, and then import it back without loss of main content, this is
579 into the Notebook without loss of main content. However,
480 in general *not guaranteed to work*. First, there is extra metadata
580 in general this is *not guaranteed* to work. First, there is extra metadata
481 saved in the notebook that may not be saved to the ``.py`` format. And as
581 saved in the notebook that may not be saved to the ``.py`` format. Second,
482 the notebook format evolves in complexity, there will be attributes of the
582 as the notebook format evolves in complexity, there will be attributes of
483 notebook that will not survive a roundtrip through the Python form. You
583 the notebook that will not survive a roundtrip through the Python form. You
584 should think of the Python format as a way to output a script version of a
484 should think of the Python format as a way to output a script version of a
585 notebook and the import capabilities as a way to load existing code to get
485 notebook and the import capabilities as a way to load existing code to get
586 a notebook started. But the Python version is *not* an alternate notebook
486 a notebook started. But the Python version is *not* an alternate notebook
587 format.
487 format.
588
488
589 .. seealso::
489 .. seealso::
590 :ref:`notebook_format`
490 :ref:`notebook_format`
491
492 .. include:: ../links.txt
@@ -1,187 +1,164 b''
1 .. _working_remotely.txt
1 .. _working_remotely.txt
2
2
3 Working remotely
3 Running a notebook server
4 ================
4 =========================
5
5
6
6
7 The IPython Notebook web app is based on a server-client structure.
7 The :ref:`IPython notebook <htmlnotebook>` web-application is based on a
8 This server uses a two-process kernel architecture based on ZeroMQ_, as well
8 server-client structure. This server uses a :ref:`two-process kernel
9 as Tornado_ for serving HTTP requests. Other clients may connect to the same
9 architecture <ipythonzmq>` based on ZeroMQ_, as well as Tornado_ for serving
10 underlying IPython kernel; see below.
10 HTTP requests. By default, a notebook server runs on http://127.0.0.1:8888/
11 and is accessible only from `localhost`. This document describes how you can
12 :ref:`secure a notebook server <notebook_security>` and how to :ref:`run it on
13 a public interface <notebook_public_server>`.
11
14
12 .. _ZeroMQ: http://zeromq.org
15 .. _ZeroMQ: http://zeromq.org
13
16
14 .. _Tornado: http://www.tornadoweb.org
17 .. _Tornado: http://www.tornadoweb.org
15
18
16
19
17 .. _notebook_security:
20 .. _notebook_security:
18
21
19 Security
22 Notebook security
20 --------
23 -----------------
21
24
22 You can protect your Notebook server with a simple single password by
25 You can protect your notebook server with a simple single password by
23 setting the :attr:`NotebookApp.password` configurable. You can prepare a
26 setting the :attr:`NotebookApp.password` configurable. You can prepare a
24 hashed password using the function :func:`IPython.lib.security.passwd`:
27 hashed password using the function :func:`IPython.lib.security.passwd`:
25
28
26 .. sourcecode:: ipython
29 .. sourcecode:: ipython
27
30
28 In [1]: from IPython.lib import passwd
31 In [1]: from IPython.lib import passwd
29 In [2]: passwd()
32 In [2]: passwd()
30 Enter password:
33 Enter password:
31 Verify password:
34 Verify password:
32 Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
35 Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
33
36
34 .. note::
37 .. note::
35
38
36 :func:`~IPython.lib.security.passwd` can also take the password as a string
39 :func:`~IPython.lib.security.passwd` can also take the password as a string
37 argument. **Do not** pass it as an argument inside an IPython session, as it
40 argument. **Do not** pass it as an argument inside an IPython session, as it
38 will be saved in your input history.
41 will be saved in your input history.
39
42
40 You can then add this to your :file:`ipython_notebook_config.py`, e.g.::
43 You can then add this to your :file:`ipython_notebook_config.py`, e.g.::
41
44
42 # Password to use for web authentication
45 # Password to use for web authentication
43 c = get_config()
46 c = get_config()
44 c.NotebookApp.password =
47 c.NotebookApp.password =
45 u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
48 u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
46
49
47 When using a password, it is a good idea to also use SSL, so that your
50 When using a password, it is a good idea to also use SSL, so that your
48 password is not sent unencrypted by your browser. You can start the notebook
51 password is not sent unencrypted by your browser. You can start the notebook
49 to communicate via a secure protocol mode using a self-signed certificate with
52 to communicate via a secure protocol mode using a self-signed certificate with
50 the command::
53 the command::
51
54
52 $ ipython notebook --certfile=mycert.pem
55 $ ipython notebook --certfile=mycert.pem
53
56
54 .. note::
57 .. note::
55
58
56 A self-signed certificate can be generated with ``openssl``. For example,
59 A self-signed certificate can be generated with ``openssl``. For example,
57 the following command will create a certificate valid for 365 days with
60 the following command will create a certificate valid for 365 days with
58 both the key and certificate data written to the same file::
61 both the key and certificate data written to the same file::
59
62
60 $ openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.
63 $ openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.
61 pem -out mycert.pem
64 pem -out mycert.pem
62
65
63 Your browser will warn you of a dangerous certificate because it is
66 Your browser will warn you of a dangerous certificate because it is
64 self-signed. If you want to have a fully compliant certificate that will not
67 self-signed. If you want to have a fully compliant certificate that will not
65 raise warnings, it is possible (but rather involved) to obtain one,
68 raise warnings, it is possible (but rather involved) to obtain one,
66 as explained in detail in `this tutorial`__.
69 as explained in detail in `this tutorial`__.
67
70
68 .. __: http://arstechnica.com/security/news/2009/12/how-to-get-set-with-a-
71 .. __: http://arstechnica.com/security/news/2009/12/how-to-get-set-with-a-secure-sertificate-for-free.ars
69 secure-sertificate-for-free.ars
70
72
71 Keep in mind that when you enable SSL support, you will need to access the
73 Keep in mind that when you enable SSL support, you will need to access the
72 notebook server over ``https://``, not over plain ``http://``. The startup
74 notebook server over ``https://``, not over plain ``http://``. The startup
73 message from the server prints this, but it is easy to overlook and think the
75 message from the server prints this, but it is easy to overlook and think the
74 server is for some reason non-responsive.
76 server is for some reason non-responsive.
75
77
76
78
77 Connecting to an existing kernel
79 .. _notebook_public_server:
78 ---------------------------------
79
80 The notebook server always prints to the terminal the full details of
81 how to connect to each kernel, with messages such as the following::
82
83 [IPKernelApp] To connect another client to this kernel, use:
84 [IPKernelApp] --existing kernel-3bb93edd-6b5a-455c-99c8-3b658f45dde5.json
85
86 This long string is the name of a JSON file that contains all the port and
87 validation information necessary to connect to the kernel. You can then, for
88 example, manually start a Qt console connected to the *same* kernel with::
89
90 $ ipython qtconsole --existing
91 kernel-3bb93edd-6b5a-455c-99c8-3b658f45dde5.json
92
93 If you have only a single kernel running, simply typing::
94
95 $ ipython qtconsole --existing
96
97 will automatically find it. (It will always find the most recently
98 started kernel if there is more than one.) You can also request this
99 connection data by typing ``%connect_info``; this will print the same
100 file information as well as the content of the JSON data structure it
101 contains.
102
103
80
104 Running a public notebook server
81 Running a public notebook server
105 --------------------------------
82 --------------------------------
106
83
107 If you want to access your notebook server remotely via a web browser,
84 If you want to access your notebook server remotely via a web browser,
108 you can do the following.
85 you can do the following.
109
86
110 Start by creating a certificate file and a hashed password, as explained
87 Start by creating a certificate file and a hashed password, as explained
111 above. Then create a custom profile for the notebook, with the following
88 above. Then create a custom profile for the notebook, with the following
112 command line, type::
89 command line, type::
113
90
114 $ ipython profile create nbserver
91 $ ipython profile create nbserver
115
92
116 In the profile directory just created, edit the file
93 In the profile directory just created, edit the file
117 ``ipython_notebook_config.py``. By default, the file has all fields
94 ``ipython_notebook_config.py``. By default, the file has all fields
118 commented; the minimum set you need to uncomment and edit is the following::
95 commented; the minimum set you need to uncomment and edit is the following::
119
96
120 c = get_config()
97 c = get_config()
121
98
122 # Kernel config
99 # Kernel config
123 c.IPKernelApp.pylab = 'inline' # if you want plotting support always
100 c.IPKernelApp.pylab = 'inline' # if you want plotting support always
124
101
125 # Notebook config
102 # Notebook config
126 c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/mycert.pem'
103 c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/mycert.pem'
127 c.NotebookApp.ip = '*'
104 c.NotebookApp.ip = '*'
128 c.NotebookApp.open_browser = False
105 c.NotebookApp.open_browser = False
129 c.NotebookApp.password = u'sha1:bcd259ccf...[your hashed password here]'
106 c.NotebookApp.password = u'sha1:bcd259ccf...[your hashed password here]'
130 # It is a good idea to put it on a known, fixed port
107 # It is a good idea to put it on a known, fixed port
131 c.NotebookApp.port = 9999
108 c.NotebookApp.port = 9999
132
109
133 You can then start the notebook and access it later by pointing your browser
110 You can then start the notebook and access it later by pointing your browser
134 to ``https://your.host.com:9999`` with ``ipython notebook
111 to ``https://your.host.com:9999`` with ``ipython notebook
135 --profile=nbserver``.
112 --profile=nbserver``.
136
113
137 Running with a different URL prefix
114 Running with a different URL prefix
138 -----------------------------------
115 -----------------------------------
139
116
140 The notebook dashboard (the landing page with an overview
117 The notebook dashboard (the landing page with an overview
141 of the notebooks in your working directory) typically lives at the URL
118 of the notebooks in your working directory) typically lives at the URL
142 ``http://localhost:8888/``. If you prefer that it lives, together with the
119 ``http://localhost:8888/``. If you prefer that it lives, together with the
143 rest of the notebook, under a sub-directory,
120 rest of the notebook, under a sub-directory,
144 e.g. ``http://localhost:8888/ipython/``, you can do so with
121 e.g. ``http://localhost:8888/ipython/``, you can do so with
145 configuration options like the following (see above for instructions about
122 configuration options like the following (see above for instructions about
146 modifying ``ipython_notebook_config.py``)::
123 modifying ``ipython_notebook_config.py``)::
147
124
148 c.NotebookApp.base_project_url = '/ipython/'
125 c.NotebookApp.base_project_url = '/ipython/'
149 c.NotebookApp.base_kernel_url = '/ipython/'
126 c.NotebookApp.base_kernel_url = '/ipython/'
150 c.NotebookApp.webapp_settings = {'static_url_prefix':'/ipython/static/'}
127 c.NotebookApp.webapp_settings = {'static_url_prefix':'/ipython/static/'}
151
128
152 Using a different notebook store
129 Using a different notebook store
153 --------------------------------
130 --------------------------------
154
131
155 By default, the Notebook app stores the notebook documents that it saves as
132 By default, the notebook server stores the notebook documents that it saves as
156 files in the working directory of the Notebook app, also known as the
133 files in the working directory of the notebook server, also known as the
157 ``notebook_dir``. This logic is implemented in the
134 ``notebook_dir``. This logic is implemented in the
158 :class:`FileNotebookManager` class. However, the server can be configured to
135 :class:`FileNotebookManager` class. However, the server can be configured to
159 use a different notebook manager class, which can
136 use a different notebook manager class, which can
160 store the notebooks in a different format.
137 store the notebooks in a different format.
161
138
162 Currently, we ship a :class:`AzureNotebookManager` class that stores notebooks
139 Currently, we ship a :class:`AzureNotebookManager` class that stores notebooks
163 in Azure blob storage. This can be used by adding the following lines to your
140 in Azure blob storage. This can be used by adding the following lines to your
164 ``ipython_notebook_config.py`` file::
141 ``ipython_notebook_config.py`` file::
165
142
166 c.NotebookApp.notebook_manager_class =
143 c.NotebookApp.notebook_manager_class =
167 'IPython.html.services.notebooks.azurenbmanager.AzureNotebookManager'
144 'IPython.html.services.notebooks.azurenbmanager.AzureNotebookManager'
168 c.AzureNotebookManager.account_name = u'paste_your_account_name_here'
145 c.AzureNotebookManager.account_name = u'paste_your_account_name_here'
169 c.AzureNotebookManager.account_key = u'paste_your_account_key_here'
146 c.AzureNotebookManager.account_key = u'paste_your_account_key_here'
170 c.AzureNotebookManager.container = u'notebooks'
147 c.AzureNotebookManager.container = u'notebooks'
171
148
172 In addition to providing your Azure Blob Storage account name and key, you
149 In addition to providing your Azure Blob Storage account name and key, you
173 will have to provide a container name; you can use multiple containers to
150 will have to provide a container name; you can use multiple containers to
174 organize your notebooks.
151 organize your notebooks.
175
152
176
153
177 Known issues
154 Known issues
178 ------------
155 ------------
179
156
180 When behind a proxy, especially if your system or browser is set to autodetect
157 When behind a proxy, especially if your system or browser is set to autodetect
181 the proxy, the Notebook app might fail to connect to the server's websockets,
158 the proxy, the notebook web application might fail to connect to the server's
182 and present you with a warning at startup. In this case, you need to configure
159 websockets, and present you with a warning at startup. In this case, you need
183 your system not to use the proxy for the server's address.
160 to configure your system not to use the proxy for the server's address.
184
161
185 For example, in Firefox, go to the Preferences panel, Advanced section,
162 For example, in Firefox, go to the Preferences panel, Advanced section,
186 Network tab, click 'Settings...', and add the address of the notebook server
163 Network tab, click 'Settings...', and add the address of the notebook server
187 to the 'No proxy for' field.
164 to the 'No proxy for' field.
@@ -1,179 +1,202 b''
1 .. _tutorial:
1 .. _tutorial:
2
2
3 ======================
3 ======================
4 Introducing IPython
4 Introducing IPython
5 ======================
5 ======================
6
6
7 You don't need to know anything beyond Python to start using IPython – just type
7 You don't need to know anything beyond Python to start using IPython – just type
8 commands as you would at the standard Python prompt. But IPython can do much
8 commands as you would at the standard Python prompt. But IPython can do much
9 more than the standard prompt. Some key features are described here. For more
9 more than the standard prompt. Some key features are described here. For more
10 information, check the :ref:`tips page <tips>`, or look at examples in the
10 information, check the :ref:`tips page <tips>`, or look at examples in the
11 `IPython cookbook <http://wiki.ipython.org/index.php?title=Cookbook>`_.
11 `IPython cookbook <https://github.com/ipython/ipython/wiki/Cookbook%3A-Index>`_.
12
12
13 If you've never used Python before, you might want to look at `the official
13 If you've never used Python before, you might want to look at `the official
14 tutorial <http://docs.python.org/tutorial/>`_ or an alternative, `Dive into
14 tutorial <http://docs.python.org/tutorial/>`_ or an alternative, `Dive into
15 Python <http://diveintopython.org/toc/index.html>`_.
15 Python <http://diveintopython.org/toc/index.html>`_.
16
16
17 The four most helpful commands
18 ===============================
19
20 The four most helpful commands, as well as their brief description, is shown
21 to you in a banner, every time you start IPython:
22
23 ========== =========================================================
24 command description
25 ========== =========================================================
26 ? Introduction and overview of IPython's features.
27 %quickref Quick reference.
28 help Python's own help system.
29 object? Details about 'object', use 'object??' for extra details.
30 ========== =========================================================
31
17 Tab completion
32 Tab completion
18 ==============
33 ==============
19
34
20 Tab completion, especially for attributes, is a convenient way to explore the
35 Tab completion, especially for attributes, is a convenient way to explore the
21 structure of any object you're dealing with. Simply type ``object_name.<TAB>``
36 structure of any object you're dealing with. Simply type ``object_name.<TAB>``
22 to view the object's attributes (see :ref:`the readline section <readline>` for
37 to view the object's attributes (see :ref:`the readline section <readline>` for
23 more). Besides Python objects and keywords, tab completion also works on file
38 more). Besides Python objects and keywords, tab completion also works on file
24 and directory names.
39 and directory names.
25
40
26 Exploring your objects
41 Exploring your objects
27 ======================
42 ======================
28
43
29 Typing ``object_name?`` will print all sorts of details about any object,
44 Typing ``object_name?`` will print all sorts of details about any object,
30 including docstrings, function definition lines (for call arguments) and
45 including docstrings, function definition lines (for call arguments) and
31 constructor details for classes. To get specific information on an object, you
46 constructor details for classes. To get specific information on an object, you
32 can use the magic commands ``%pdoc``, ``%pdef``, ``%psource`` and ``%pfile``
47 can use the magic commands ``%pdoc``, ``%pdef``, ``%psource`` and ``%pfile``
33
48
49 .. _magics_explained:
50
34 Magic functions
51 Magic functions
35 ===============
52 ===============
36
53
37 IPython has a set of predefined 'magic functions' that you can call with a
54 IPython has a set of predefined 'magic functions' that you can call with a
38 command line style syntax. There are two kinds of magics, line-oriented and
55 command line style syntax. There are two kinds of magics, line-oriented and
39 cell-oriented. Line magics are prefixed with the ``%`` character and work much
56 cell-oriented. **Line magics** are prefixed with the ``%`` character and work much
40 like OS command-line calls: they get as an argument the rest of the line, where
57 like OS command-line calls: they get as an argument the rest of the line, where
41 arguments are passed without parentheses or quotes. Cell magics are prefixed
58 arguments are passed without parentheses or quotes. **Cell magics** are
42 with a double ``%%``, and they are functions that get as an argument not only
59 prefixed with a double ``%%``, and they are functions that get as an argument
43 the rest of the line, but also the lines below it in a separate argument.
60 not only the rest of the line, but also the lines below it in a separate
61 argument.
44
62
45 The following examples show how to call the builtin ``timeit`` magic, both in
63 The following examples show how to call the builtin ``timeit`` magic, both in
46 line and cell mode::
64 line and cell mode::
47
65
48 In [1]: %timeit range(1000)
66 In [1]: %timeit range(1000)
49 100000 loops, best of 3: 7.76 us per loop
67 100000 loops, best of 3: 7.76 us per loop
50
68
51 In [2]: %%timeit x = range(10000)
69 In [2]: %%timeit x = range(10000)
52 ...: max(x)
70 ...: max(x)
53 ...:
71 ...:
54 1000 loops, best of 3: 223 us per loop
72 1000 loops, best of 3: 223 us per loop
55
73
56 The builtin magics include:
74 The builtin magics include:
57
75
58 - Functions that work with code: ``%run``, ``%edit``, ``%save``, ``%macro``,
76 - Functions that work with code: ``%run``, ``%edit``, ``%save``, ``%macro``,
59 ``%recall``, etc.
77 ``%recall``, etc.
60 - Functions which affect the shell: ``%colors``, ``%xmode``, ``%autoindent``,
78 - Functions which affect the shell: ``%colors``, ``%xmode``, ``%autoindent``,
61 etc.
79 ``%automagic``, etc.
62 - Other functions such as ``%reset``, ``%timeit`` or ``%paste``.
80 - Other functions such as ``%reset``, ``%timeit``, ``%%file``, ``%load``, or
81 ``%paste``.
63
82
64 You can always call them using the % prefix, and if you're calling a line magic
83 You can always call them using the ``%`` prefix, and if you're calling a line
65 on a line by itself, you can omit even that (cell magics must always have the
84 magic on a line by itself, you can omit even that::
66 ``%%`` prefix)::
67
85
68 run thescript.py
86 run thescript.py
69
87
88 You can toggle this behavior by running the ``%automagic`` magic. Cell magics
89 must always have the ``%%`` prefix.
90
70 A more detailed explanation of the magic system can be obtained by calling
91 A more detailed explanation of the magic system can be obtained by calling
71 ``%magic``, and for more details on any magic function, call ``%somemagic?`` to
92 ``%magic``, and for more details on any magic function, call ``%somemagic?`` to
72 read its docstring. To see all the available magic functions, call
93 read its docstring. To see all the available magic functions, call
73 ``%lsmagic``.
94 ``%lsmagic``.
74
95
96 .. seealso::
97
98 `Cell magics`_ example notebook
99
75 Running and Editing
100 Running and Editing
76 -------------------
101 -------------------
77
102
78 The %run magic command allows you to run any python script and load all of its
103 The ``%run`` magic command allows you to run any python script and load all of
79 data directly into the interactive namespace. Since the file is re-read from
104 its data directly into the interactive namespace. Since the file is re-read
80 disk each time, changes you make to it are reflected immediately (unlike
105 from disk each time, changes you make to it are reflected immediately (unlike
81 imported modules, which have to be specifically reloaded). IPython also includes
106 imported modules, which have to be specifically reloaded). IPython also
82 :ref:`dreload <dreload>`, a recursive reload function.
107 includes :ref:`dreload <dreload>`, a recursive reload function.
83
108
84 %run has special flags for timing the execution of your scripts (-t), or for
109 ``%run`` has special flags for timing the execution of your scripts (-t), or
85 running them under the control of either Python's pdb debugger (-d) or
110 for running them under the control of either Python's pdb debugger (-d) or
86 profiler (-p).
111 profiler (-p).
87
112
88 The %edit command gives a reasonable approximation of multiline editing,
113 The ``%edit`` command gives a reasonable approximation of multiline editing,
89 by invoking your favorite editor on the spot. IPython will execute the
114 by invoking your favorite editor on the spot. IPython will execute the
90 code you type in there as if it were typed interactively.
115 code you type in there as if it were typed interactively.
91
116
92 Debugging
117 Debugging
93 ---------
118 ---------
94
119
95 After an exception occurs, you can call ``%debug`` to jump into the Python
120 After an exception occurs, you can call ``%debug`` to jump into the Python
96 debugger (pdb) and examine the problem. Alternatively, if you call ``%pdb``,
121 debugger (pdb) and examine the problem. Alternatively, if you call ``%pdb``,
97 IPython will automatically start the debugger on any uncaught exception. You can
122 IPython will automatically start the debugger on any uncaught exception. You can
98 print variables, see code, execute statements and even walk up and down the
123 print variables, see code, execute statements and even walk up and down the
99 call stack to track down the true source of the problem. This can be an efficient
124 call stack to track down the true source of the problem. This can be an efficient
100 way to develop and debug code, in many cases eliminating the need for print
125 way to develop and debug code, in many cases eliminating the need for print
101 statements or external debugging tools.
126 statements or external debugging tools.
102
127
103 You can also step through a program from the beginning by calling
128 You can also step through a program from the beginning by calling
104 ``%run -d theprogram.py``.
129 ``%run -d theprogram.py``.
105
130
106 History
131 History
107 =======
132 =======
108
133
109 IPython stores both the commands you enter, and the results it produces. You
134 IPython stores both the commands you enter, and the results it produces. You
110 can easily go through previous commands with the up- and down-arrow keys, or
135 can easily go through previous commands with the up- and down-arrow keys, or
111 access your history in more sophisticated ways.
136 access your history in more sophisticated ways.
112
137
113 Input and output history are kept in variables called ``In`` and ``Out``, keyed
138 Input and output history are kept in variables called ``In`` and ``Out``, keyed
114 by the prompt numbers, e.g. ``In[4]``. The last three objects in output history
139 by the prompt numbers, e.g. ``In[4]``. The last three objects in output history
115 are also kept in variables named ``_``, ``__`` and ``___``.
140 are also kept in variables named ``_``, ``__`` and ``___``.
116
141
117 You can use the ``%history`` magic function to examine past input and output.
142 You can use the ``%history`` magic function to examine past input and output.
118 Input history from previous sessions is saved in a database, and IPython can be
143 Input history from previous sessions is saved in a database, and IPython can be
119 configured to save output history.
144 configured to save output history.
120
145
121 Several other magic functions can use your input history, including ``%edit``,
146 Several other magic functions can use your input history, including ``%edit``,
122 ``%rerun``, ``%recall``, ``%macro``, ``%save`` and ``%pastebin``. You can use a
147 ``%rerun``, ``%recall``, ``%macro``, ``%save`` and ``%pastebin``. You can use a
123 standard format to refer to lines::
148 standard format to refer to lines::
124
149
125 %pastebin 3 18-20 ~1/1-5
150 %pastebin 3 18-20 ~1/1-5
126
151
127 This will take line 3 and lines 18 to 20 from the current session, and lines
152 This will take line 3 and lines 18 to 20 from the current session, and lines
128 1-5 from the previous session.
153 1-5 from the previous session.
129
154
130 System shell commands
155 System shell commands
131 =====================
156 =====================
132
157
133 To run any command at the system shell, simply prefix it with !, e.g.::
158 To run any command at the system shell, simply prefix it with !, e.g.::
134
159
135 !ping www.bbc.co.uk
160 !ping www.bbc.co.uk
136
161
137 You can capture the output into a Python list, e.g.: ``files = !ls``. To pass
162 You can capture the output into a Python list, e.g.: ``files = !ls``. To pass
138 the values of Python variables or expressions to system commands, prefix them
163 the values of Python variables or expressions to system commands, prefix them
139 with $: ``!grep -rF $pattern ipython/*``. See :ref:`our shell section
164 with $: ``!grep -rF $pattern ipython/*``. See :ref:`our shell section
140 <system_shell_access>` for more details.
165 <system_shell_access>` for more details.
141
166
142 Define your own system aliases
167 Define your own system aliases
143 ------------------------------
168 ------------------------------
144
169
145 It's convenient to have aliases to the system commands you use most often.
170 It's convenient to have aliases to the system commands you use most often.
146 This allows you to work seamlessly from inside IPython with the same commands
171 This allows you to work seamlessly from inside IPython with the same commands
147 you are used to in your system shell. IPython comes with some pre-defined
172 you are used to in your system shell. IPython comes with some pre-defined
148 aliases and a complete system for changing directories, both via a stack (see
173 aliases and a complete system for changing directories, both via a stack (see
149 %pushd, %popd and %dhist) and via direct %cd. The latter keeps a history of
174 %pushd, %popd and %dhist) and via direct %cd. The latter keeps a history of
150 visited directories and allows you to go to any previously visited one.
175 visited directories and allows you to go to any previously visited one.
151
176
152
177
153 Configuration
178 Configuration
154 =============
179 =============
155
180
156 Much of IPython can be tweaked through configuration. To get started, use the
181 Much of IPython can be tweaked through :ref:`configuration <config_overview>`.
157 command ``ipython profile create`` to produce the default config files. These
182 To get started, use the command ``ipython profile create`` to produce the
158 will be placed in :file:`~/.ipython/profile_default` or
183 default config files. These will be placed in
159 :file:`~/.config/ipython/profile_default`, and contain comments explaining what
184 :file:`~/.ipython/profile_default` or
160 the various options do.
185 :file:`~/.config/ipython/profile_default`, and contain comments explaining
186 what the various options do.
161
187
162 Profiles allow you to use IPython for different tasks, keeping separate config
188 Profiles allow you to use IPython for different tasks, keeping separate config
163 files and history for each one. More details in :ref:`the profiles section
189 files and history for each one. More details in :ref:`the profiles section
164 <profiles>`.
190 <profiles>`.
165
191
166 Startup Files
192 Startup Files
167 -------------
193 -------------
168
194
169 If you want some code to be run at the beginning of every IPython session, the
195 If you want some code to be run at the beginning of every IPython session, the
170 easiest way is to add Python (.py) or IPython (.ipy) scripts to your
196 easiest way is to add Python (.py) or IPython (.ipy) scripts to your
171 :file:`profile_default/startup/` directory. Files here will be executed as soon
197 :file:`profile_default/startup/` directory. Files here will be executed as soon
172 as the IPython shell is constructed, before any other code or scripts you have
198 as the IPython shell is constructed, before any other code or scripts you have
173 specified. The files will be run in order of their names, so you can control the
199 specified. The files will be run in order of their names, so you can control the
174 ordering with prefixes, like ``10-myimports.py``.
200 ordering with prefixes, like ``10-myimports.py``.
175
201
176 .. note::
202 .. include:: ../links.txt
177
178 Automatic startup files are new in IPython 0.12. Use InteractiveShellApp.exec_files
179 in :file:`ipython_config.py` for similar behavior in 0.11.
@@ -1,75 +1,101 b''
1 .. This (-*- rst -*-) format file contains commonly used link targets
1 .. This (-*- rst -*-) format file contains commonly used link targets
2 and name substitutions. It may be included in many files,
2 and name substitutions. It may be included in many files,
3 therefore it should only contain link targets and name
3 therefore it should only contain link targets and name
4 substitutions. Try grepping for "^\.\. _" to find plausible
4 substitutions. Try grepping for "^\.\. _" to find plausible
5 candidates for this list.
5 candidates for this list.
6
6
7 NOTE: this file must have an extension *opposite* to that of the main reST
7 NOTE: this file must have an extension *opposite* to that of the main reST
8 files in the manuals, so that we can include it with ".. include::"
8 files in the manuals, so that we can include it with ".. include::"
9 directives, but without triggering warnings from Sphinx for not being listed
9 directives, but without triggering warnings from Sphinx for not being listed
10 in any toctree. Since IPython uses .txt for the main files, this wone will
10 in any toctree. Since IPython uses .txt for the main files, this wone will
11 use .rst.
11 use .rst.
12
12
13 NOTE: reST targets are
13 NOTE: reST targets are
14 __not_case_sensitive__, so only one target definition is needed for
14 __not_case_sensitive__, so only one target definition is needed for
15 ipython, IPython, etc.
15 ipython, IPython, etc.
16
16
17 NOTE: Some of these were taken from the nipy links compendium.
17 NOTE: Some of these were taken from the nipy links compendium.
18
18
19 .. Main IPython links
19 .. Main IPython links
20 .. _ipython: http://ipython.org
20 .. _ipython: http://ipython.org
21 .. _`ipython manual`: http://ipython.org/documentation.html
21 .. _`ipython manual`: http://ipython.org/documentation.html
22 .. _ipython_github: http://github.com/ipython/ipython/
22 .. _ipython_github: http://github.com/ipython/ipython/
23 .. _ipython_github_repo: http://github.com/ipython/ipython/
23 .. _ipython_github_repo: http://github.com/ipython/ipython/
24 .. _ipython_downloads: http://ipython.org/download.html
24 .. _ipython_downloads: http://ipython.org/download.html
25 .. _ipython_pypi: http://pypi.python.org/pypi/ipython
25 .. _ipython_pypi: http://pypi.python.org/pypi/ipython
26 .. _nbviewer: http://nbviewer.ipython.org
26
27
27 .. _ZeroMQ: http://zeromq.org
28 .. _ZeroMQ: http://zeromq.org
28
29
29 .. Documentation tools and related links
30 .. Documentation tools and related links
30 .. _graphviz: http://www.graphviz.org
31 .. _graphviz: http://www.graphviz.org
31 .. _Sphinx: http://sphinx.pocoo.org
32 .. _Sphinx: http://sphinx.pocoo.org
32 .. _`Sphinx reST`: http://sphinx.pocoo.org/rest.html
33 .. _`Sphinx reST`: http://sphinx.pocoo.org/rest.html
33 .. _sampledoc: http://matplotlib.sourceforge.net/sampledoc
34 .. _sampledoc: http://matplotlib.sourceforge.net/sampledoc
34 .. _reST: http://docutils.sourceforge.net/rst.html
35 .. _reST: http://docutils.sourceforge.net/rst.html
35 .. _docutils: http://docutils.sourceforge.net
36 .. _docutils: http://docutils.sourceforge.net
36 .. _lyx: http://www.lyx.org
37 .. _lyx: http://www.lyx.org
37 .. _pep8: http://www.python.org/dev/peps/pep-0008
38 .. _pep8: http://www.python.org/dev/peps/pep-0008
38 .. _numpy_coding_guide: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt
39 .. _numpy_coding_guide: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt
39
40
40 .. Licenses
41 .. Licenses
41 .. _GPL: http://www.gnu.org/licenses/gpl.html
42 .. _GPL: http://www.gnu.org/licenses/gpl.html
42 .. _BSD: http://www.opensource.org/licenses/bsd-license.php
43 .. _BSD: http://www.opensource.org/licenses/bsd-license.php
43 .. _LGPL: http://www.gnu.org/copyleft/lesser.html
44 .. _LGPL: http://www.gnu.org/copyleft/lesser.html
44
45
45 .. Other python projects
46 .. Other python projects
46 .. _numpy: http://numpy.scipy.org
47 .. _numpy: http://numpy.scipy.org
47 .. _scipy: http://www.scipy.org
48 .. _scipy: http://www.scipy.org
48 .. _scipy_conference: http://conference.scipy.org
49 .. _scipy_conference: http://conference.scipy.org
49 .. _matplotlib: http://matplotlib.sourceforge.net
50 .. _matplotlib: http://matplotlib.org
50 .. _pythonxy: http://www.pythonxy.com
51 .. _pythonxy: http://www.pythonxy.com
51 .. _ETS: http://code.enthought.com/projects/tool-suite.php
52 .. _ETS: http://code.enthought.com/projects/tool-suite.php
52 .. _EPD: http://www.enthought.com/products/epd.php
53 .. _EPD: http://www.enthought.com/products/epd.php
53 .. _python: http://www.python.org
54 .. _python: http://www.python.org
54 .. _mayavi: http://code.enthought.com/projects/mayavi
55 .. _mayavi: http://code.enthought.com/projects/mayavi
55 .. _sympy: http://code.google.com/p/sympy
56 .. _sympy: http://code.google.com/p/sympy
56 .. _sage: http://sagemath.org
57 .. _sage: http://sagemath.org
57 .. _pydy: http://code.google.com/p/pydy
58 .. _pydy: http://code.google.com/p/pydy
58 .. _vpython: http://vpython.org
59 .. _vpython: http://vpython.org
59 .. _cython: http://cython.org
60 .. _cython: http://cython.org
60 .. _software carpentry: http://software-carpentry.org
61 .. _software carpentry: http://software-carpentry.org
61
62
62 .. Not so python scientific computing tools
63 .. Not so python scientific computing tools
63 .. _matlab: http://www.mathworks.com
64 .. _matlab: http://www.mathworks.com
64 .. _VTK: http://vtk.org
65 .. _VTK: http://vtk.org
65
66
66 .. Other organizations
67 .. Other organizations
67 .. _enthought: http://www.enthought.com
68 .. _enthought: http://www.enthought.com
68 .. _kitware: http://www.kitware.com
69 .. _kitware: http://www.kitware.com
69 .. _netlib: http://netlib.org
70 .. _netlib: http://netlib.org
70
71
71 .. Other tools and projects
72 .. Other tools and projects
72 .. _indefero: http://www.indefero.net
73 .. _indefero: http://www.indefero.net
73 .. _git: http://git-scm.com
74 .. _git: http://git-scm.com
74 .. _github: http://github.com
75 .. _github: http://github.com
75 .. _MarkDown: http://daringfireball.net/projects/markdown/
76 .. _Markdown: http://daringfireball.net/projects/markdown/syntax
77
78 .. _Running Code in the IPython Notebook: notebook_p1_
79 .. _notebook_p1: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Part%25201%2520-%2520Running%2520Code.ipynb
80
81 .. _Basic Output: notebook_p2_
82 .. _notebook_p2: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Part%202%20-%20Basic%20Output.ipynb
83
84 .. _Plotting with Matplotlib: notebook_p3_
85 .. _notebook_p3: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Part%203%20-%20Plotting%20with%20Matplotlib.ipynb
86
87 .. _Markdown Cells: notebook_p4
88 .. _notebook_p4: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Part%204%20-%20Markdown%20Cells.ipynb
89
90 .. _Rich Display System: notebook_p5_
91 .. _notebook_p5: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Part%205%20-%20Rich%20Display%20System.ipynb
92
93 .. _notebook_custom_display: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Custom%20Display%20Logic.ipynb
94
95 .. _Frontend/Kernel Model: notebook_two_proc_
96 .. _notebook_two_proc: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Frontend-Kernel%20Model.ipynb
97
98 .. _Cell magics: notebook_cell_magics_
99 .. _notebook_cell_magics: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Cell%20Magics.ipynb
100
101
@@ -1,285 +1,290 b''
1 .. _overview:
1 .. _overview:
2
2
3 ============
3 ============
4 Introduction
4 Introduction
5 ============
5 ============
6
6
7 Overview
7 Overview
8 ========
8 ========
9
9
10 One of Python's most useful features is its interactive interpreter.
10 One of Python's most useful features is its interactive interpreter.
11 It allows for very fast testing of ideas without the overhead of
11 It allows for very fast testing of ideas without the overhead of
12 creating test files as is typical in most programming languages.
12 creating test files as is typical in most programming languages.
13 However, the interpreter supplied with the standard Python distribution
13 However, the interpreter supplied with the standard Python distribution
14 is somewhat limited for extended interactive use.
14 is somewhat limited for extended interactive use.
15
15
16 The goal of IPython is to create a comprehensive environment for
16 The goal of IPython is to create a comprehensive environment for
17 interactive and exploratory computing. To support this goal, IPython
17 interactive and exploratory computing. To support this goal, IPython
18 has three main components:
18 has three main components:
19
19
20 * An enhanced interactive Python shell.
20 * An enhanced interactive Python shell.
21 * A decoupled two-process communication model, which allows for multiple
21 * A decoupled :ref:`two-process communication model <ipythonzmq>`, which
22 clients to connect to a computation kernel, most notably the web-based
22 allows for multiple clients to connect to a computation kernel, most notably
23 :ref:`notebook <htmlnotebook>`
23 the web-based :ref:`notebook <htmlnotebook>`
24 * An architecture for interactive parallel computing.
24 * An architecture for interactive parallel computing.
25
25
26 All of IPython is open source (released under the revised BSD license).
26 All of IPython is open source (released under the revised BSD license).
27
27
28 Enhanced interactive Python shell
28 Enhanced interactive Python shell
29 =================================
29 =================================
30
30
31 IPython's interactive shell (:command:`ipython`), has the following goals,
31 IPython's interactive shell (:command:`ipython`), has the following goals,
32 amongst others:
32 amongst others:
33
33
34 1. Provide an interactive shell superior to Python's default. IPython
34 1. Provide an interactive shell superior to Python's default. IPython
35 has many features for tab-completion, object introspection, system shell
35 has many features for tab-completion, object introspection, system shell
36 access, command history retrieval across sessions, and its own special
36 access, command history retrieval across sessions, and its own special
37 command system for adding functionality when working interactively. It
37 command system for adding functionality when working interactively. It
38 tries to be a very efficient environment both for Python code development
38 tries to be a very efficient environment both for Python code development
39 and for exploration of problems using Python objects (in situations like
39 and for exploration of problems using Python objects (in situations like
40 data analysis).
40 data analysis).
41
41
42 2. Serve as an embeddable, ready to use interpreter for your own
42 2. Serve as an embeddable, ready to use interpreter for your own
43 programs. An interactive IPython shell can be started with a single call
43 programs. An interactive IPython shell can be started with a single call
44 from inside another program, providing access to the current namespace.
44 from inside another program, providing access to the current namespace.
45 This can be very useful both for debugging purposes and for situations
45 This can be very useful both for debugging purposes and for situations
46 where a blend of batch-processing and interactive exploration are needed.
46 where a blend of batch-processing and interactive exploration are needed.
47
47
48 3. Offer a flexible framework which can be used as the base
48 3. Offer a flexible framework which can be used as the base
49 environment for working with other systems, with Python as the underlying
49 environment for working with other systems, with Python as the underlying
50 bridge language. Specifically scientific environments like Mathematica,
50 bridge language. Specifically scientific environments like Mathematica,
51 IDL and Matlab inspired its design, but similar ideas can be
51 IDL and Matlab inspired its design, but similar ideas can be
52 useful in many fields.
52 useful in many fields.
53
53
54 4. Allow interactive testing of threaded graphical toolkits. IPython
54 4. Allow interactive testing of threaded graphical toolkits. IPython
55 has support for interactive, non-blocking control of GTK, Qt, WX, GLUT, and
55 has support for interactive, non-blocking control of GTK, Qt, WX, GLUT, and
56 OS X applications via special threading flags. The normal Python
56 OS X applications via special threading flags. The normal Python
57 shell can only do this for Tkinter applications.
57 shell can only do this for Tkinter applications.
58
58
59 Main features of the interactive shell
59 Main features of the interactive shell
60 --------------------------------------
60 --------------------------------------
61
61
62 * Dynamic object introspection. One can access docstrings, function
62 * Dynamic object introspection. One can access docstrings, function
63 definition prototypes, source code, source files and other details
63 definition prototypes, source code, source files and other details
64 of any object accessible to the interpreter with a single
64 of any object accessible to the interpreter with a single
65 keystroke (:samp:`?`, and using :samp:`??` provides additional detail).
65 keystroke (:samp:`?`, and using :samp:`??` provides additional detail).
66
66
67 * Searching through modules and namespaces with :samp:`*` wildcards, both
67 * Searching through modules and namespaces with :samp:`*` wildcards, both
68 when using the :samp:`?` system and via the :samp:`%psearch` command.
68 when using the :samp:`?` system and via the :samp:`%psearch` command.
69
69
70 * Completion in the local namespace, by typing :kbd:`TAB` at the prompt.
70 * Completion in the local namespace, by typing :kbd:`TAB` at the prompt.
71 This works for keywords, modules, methods, variables and files in the
71 This works for keywords, modules, methods, variables and files in the
72 current directory. This is supported via the readline library, and
72 current directory. This is supported via the readline library, and
73 full access to configuring readline's behavior is provided.
73 full access to configuring readline's behavior is provided.
74 Custom completers can be implemented easily for different purposes
74 Custom completers can be implemented easily for different purposes
75 (system commands, magic arguments etc.)
75 (system commands, magic arguments etc.)
76
76
77 * Numbered input/output prompts with command history (persistent
77 * Numbered input/output prompts with command history (persistent
78 across sessions and tied to each profile), full searching in this
78 across sessions and tied to each profile), full searching in this
79 history and caching of all input and output.
79 history and caching of all input and output.
80
80
81 * User-extensible 'magic' commands. A set of commands prefixed with
81 * User-extensible 'magic' commands. A set of commands prefixed with
82 :samp:`%` is available for controlling IPython itself and provides
82 :samp:`%` is available for controlling IPython itself and provides
83 directory control, namespace information and many aliases to
83 directory control, namespace information and many aliases to
84 common system shell commands.
84 common system shell commands.
85
85
86 * Alias facility for defining your own system aliases.
86 * Alias facility for defining your own system aliases.
87
87
88 * Complete system shell access. Lines starting with :samp:`!` are passed
88 * Complete system shell access. Lines starting with :samp:`!` are passed
89 directly to the system shell, and using :samp:`!!` or :samp:`var = !cmd`
89 directly to the system shell, and using :samp:`!!` or :samp:`var = !cmd`
90 captures shell output into python variables for further use.
90 captures shell output into python variables for further use.
91
91
92 * The ability to expand python variables when calling the system shell. In a
92 * The ability to expand python variables when calling the system shell. In a
93 shell command, any python variable prefixed with :samp:`$` is expanded. A
93 shell command, any python variable prefixed with :samp:`$` is expanded. A
94 double :samp:`$$` allows passing a literal :samp:`$` to the shell (for access
94 double :samp:`$$` allows passing a literal :samp:`$` to the shell (for access
95 to shell and environment variables like :envvar:`PATH`).
95 to shell and environment variables like :envvar:`PATH`).
96
96
97 * Filesystem navigation, via a magic :samp:`%cd` command, along with a
97 * Filesystem navigation, via a magic :samp:`%cd` command, along with a
98 persistent bookmark system (using :samp:`%bookmark`) for fast access to
98 persistent bookmark system (using :samp:`%bookmark`) for fast access to
99 frequently visited directories.
99 frequently visited directories.
100
100
101 * A lightweight persistence framework via the :samp:`%store` command, which
101 * A lightweight persistence framework via the :samp:`%store` command, which
102 allows you to save arbitrary Python variables. These get restored
102 allows you to save arbitrary Python variables. These get restored
103 when you run the :samp:`%store -r` command.
103 when you run the :samp:`%store -r` command.
104
104
105 * Automatic indentation (optional) of code as you type (through the
105 * Automatic indentation (optional) of code as you type (through the
106 readline library).
106 readline library).
107
107
108 * Macro system for quickly re-executing multiple lines of previous
108 * Macro system for quickly re-executing multiple lines of previous
109 input with a single name via the :samp:`%macro` command. Macros can be
109 input with a single name via the :samp:`%macro` command. Macros can be
110 stored persistently via :samp:`%store` and edited via :samp:`%edit`.
110 stored persistently via :samp:`%store` and edited via :samp:`%edit`.
111
111
112 * Session logging (you can then later use these logs as code in your
112 * Session logging (you can then later use these logs as code in your
113 programs). Logs can optionally timestamp all input, and also store
113 programs). Logs can optionally timestamp all input, and also store
114 session output (marked as comments, so the log remains valid
114 session output (marked as comments, so the log remains valid
115 Python source code).
115 Python source code).
116
116
117 * Session restoring: logs can be replayed to restore a previous
117 * Session restoring: logs can be replayed to restore a previous
118 session to the state where you left it.
118 session to the state where you left it.
119
119
120 * Verbose and colored exception traceback printouts. Easier to parse
120 * Verbose and colored exception traceback printouts. Easier to parse
121 visually, and in verbose mode they produce a lot of useful
121 visually, and in verbose mode they produce a lot of useful
122 debugging information (basically a terminal version of the cgitb
122 debugging information (basically a terminal version of the cgitb
123 module).
123 module).
124
124
125 * Auto-parentheses via the :samp:`%autocall` command: callable objects can be
125 * Auto-parentheses via the :samp:`%autocall` command: callable objects can be
126 executed without parentheses: :samp:`sin 3` is automatically converted to
126 executed without parentheses: :samp:`sin 3` is automatically converted to
127 :samp:`sin(3)`
127 :samp:`sin(3)`
128
128
129 * Auto-quoting: using :samp:`,`, or :samp:`;` as the first character forces
129 * Auto-quoting: using :samp:`,`, or :samp:`;` as the first character forces
130 auto-quoting of the rest of the line: :samp:`,my_function a b` becomes
130 auto-quoting of the rest of the line: :samp:`,my_function a b` becomes
131 automatically :samp:`my_function("a","b")`, while :samp:`;my_function a b`
131 automatically :samp:`my_function("a","b")`, while :samp:`;my_function a b`
132 becomes :samp:`my_function("a b")`.
132 becomes :samp:`my_function("a b")`.
133
133
134 * Extensible input syntax. You can define filters that pre-process
134 * Extensible input syntax. You can define filters that pre-process
135 user input to simplify input in special situations. This allows
135 user input to simplify input in special situations. This allows
136 for example pasting multi-line code fragments which start with
136 for example pasting multi-line code fragments which start with
137 :samp:`>>>` or :samp:`...` such as those from other python sessions or the
137 :samp:`>>>` or :samp:`...` such as those from other python sessions or the
138 standard Python documentation.
138 standard Python documentation.
139
139
140 * Flexible :ref:`configuration system <config_overview>`. It uses a
140 * Flexible :ref:`configuration system <config_overview>`. It uses a
141 configuration file which allows permanent setting of all command-line
141 configuration file which allows permanent setting of all command-line
142 options, module loading, code and file execution. The system allows
142 options, module loading, code and file execution. The system allows
143 recursive file inclusion, so you can have a base file with defaults and
143 recursive file inclusion, so you can have a base file with defaults and
144 layers which load other customizations for particular projects.
144 layers which load other customizations for particular projects.
145
145
146 * Embeddable. You can call IPython as a python shell inside your own
146 * Embeddable. You can call IPython as a python shell inside your own
147 python programs. This can be used both for debugging code or for
147 python programs. This can be used both for debugging code or for
148 providing interactive abilities to your programs with knowledge
148 providing interactive abilities to your programs with knowledge
149 about the local namespaces (very useful in debugging and data
149 about the local namespaces (very useful in debugging and data
150 analysis situations).
150 analysis situations).
151
151
152 * Easy debugger access. You can set IPython to call up an enhanced version of
152 * Easy debugger access. You can set IPython to call up an enhanced version of
153 the Python debugger (pdb) every time there is an uncaught exception. This
153 the Python debugger (pdb) every time there is an uncaught exception. This
154 drops you inside the code which triggered the exception with all the data
154 drops you inside the code which triggered the exception with all the data
155 live and it is possible to navigate the stack to rapidly isolate the source
155 live and it is possible to navigate the stack to rapidly isolate the source
156 of a bug. The :samp:`%run` magic command (with the :samp:`-d` option) can run
156 of a bug. The :samp:`%run` magic command (with the :samp:`-d` option) can run
157 any script under pdb's control, automatically setting initial breakpoints for
157 any script under pdb's control, automatically setting initial breakpoints for
158 you. This version of pdb has IPython-specific improvements, including
158 you. This version of pdb has IPython-specific improvements, including
159 tab-completion and traceback coloring support. For even easier debugger
159 tab-completion and traceback coloring support. For even easier debugger
160 access, try :samp:`%debug` after seeing an exception.
160 access, try :samp:`%debug` after seeing an exception.
161
161
162 * Profiler support. You can run single statements (similar to
162 * Profiler support. You can run single statements (similar to
163 :samp:`profile.run()`) or complete programs under the profiler's control.
163 :samp:`profile.run()`) or complete programs under the profiler's control.
164 While this is possible with standard cProfile or profile modules,
164 While this is possible with standard cProfile or profile modules,
165 IPython wraps this functionality with magic commands (see :samp:`%prun`
165 IPython wraps this functionality with magic commands (see :samp:`%prun`
166 and :samp:`%run -p`) convenient for rapid interactive work.
166 and :samp:`%run -p`) convenient for rapid interactive work.
167
167
168 * Simple timing information. You can use the :samp:`%timeit` command to get
168 * Simple timing information. You can use the :samp:`%timeit` command to get
169 the execution time of a Python statement or expression. This machinery is
169 the execution time of a Python statement or expression. This machinery is
170 intelligent enough to do more repetitions for commands that finish very
170 intelligent enough to do more repetitions for commands that finish very
171 quickly in order to get a better estimate of their running time.
171 quickly in order to get a better estimate of their running time.
172
172
173 .. sourcecode:: ipython
173 .. sourcecode:: ipython
174
174
175 In [1]: %timeit 1+1
175 In [1]: %timeit 1+1
176 10000000 loops, best of 3: 25.5 ns per loop
176 10000000 loops, best of 3: 25.5 ns per loop
177
177
178 In [2]: %timeit [math.sin(x) for x in range(5000)]
178 In [2]: %timeit [math.sin(x) for x in range(5000)]
179 1000 loops, best of 3: 719 Β΅s per loop
179 1000 loops, best of 3: 719 Β΅s per loop
180
180
181 ..
181 ..
182
182
183 To get the timing information for more than one expression, use the
183 To get the timing information for more than one expression, use the
184 :samp:`%%timeit` cell magic command.
184 :samp:`%%timeit` cell magic command.
185
185
186
186
187 * Doctest support. The special :samp:`%doctest_mode` command toggles a mode
187 * Doctest support. The special :samp:`%doctest_mode` command toggles a mode
188 to use doctest-compatible prompts, so you can use IPython sessions as
188 to use doctest-compatible prompts, so you can use IPython sessions as
189 doctest code. By default, IPython also allows you to paste existing
189 doctest code. By default, IPython also allows you to paste existing
190 doctests, and strips out the leading :samp:`>>>` and :samp:`...` prompts in
190 doctests, and strips out the leading :samp:`>>>` and :samp:`...` prompts in
191 them.
191 them.
192
192
193 .. _ipythonzmq:
193 .. _ipythonzmq:
194
194
195 Decoupled two-process model
195 Decoupled two-process model
196 ==============================
196 ==============================
197
197
198 IPython has abstracted and extended the notion of a traditional
198 IPython has abstracted and extended the notion of a traditional
199 *Read-Evaluate-Print Loop* (REPL) environment by decoupling the *evaluation*
199 *Read-Evaluate-Print Loop* (REPL) environment by decoupling the *evaluation*
200 into its own process. We call this process a kernel: it receives execution
200 into its own process. We call this process a **kernel**: it receives execution
201 instructions from clients and communicates the results back to them.
201 instructions from clients and communicates the results back to them.
202
202
203 This decoupling allows us to have several clients connected to the same
203 This decoupling allows us to have several clients connected to the same
204 kernel, and even allows clients and kernels to live on different machines.
204 kernel, and even allows clients and kernels to live on different machines.
205 With the exclusion of the traditional single process terminal-based IPython
205 With the exclusion of the traditional single process terminal-based IPython
206 (what you start if you run ``ipython`` without any subcommands), all
206 (what you start if you run ``ipython`` without any subcommands), all
207 other IPython machinery uses this two-process model. This includes ``ipython
207 other IPython machinery uses this two-process model. This includes ``ipython
208 console``, ``ipython qtconsole``, and ``ipython notebook``.
208 console``, ``ipython qtconsole``, and ``ipython notebook``.
209
209
210 As an example, this means that when you start ``ipython qtconsole``, you're
210 As an example, this means that when you start ``ipython qtconsole``, you're
211 really starting two processes, a kernel and a Qt-based client can send
211 really starting two processes, a kernel and a Qt-based client can send
212 commands to and receive results from that kernel. If there is already a kernel
212 commands to and receive results from that kernel. If there is already a kernel
213 running that you want to connect to, you can pass the ``--existing`` flag
213 running that you want to connect to, you can pass the ``--existing`` flag
214 which will skip initiating a new kernel and connect to the most recent kernel,
214 which will skip initiating a new kernel and connect to the most recent kernel,
215 instead. To connect to a specific kernel once you have several kernels
215 instead. To connect to a specific kernel once you have several kernels
216 running, use the ``%connect_info`` magic to get the unique connection file,
216 running, use the ``%connect_info`` magic to get the unique connection file,
217 which will be something like ``--existing kernel-19732.json`` but with
217 which will be something like ``--existing kernel-19732.json`` but with
218 different numbers which correspond to the Process ID of the kernel.
218 different numbers which correspond to the Process ID of the kernel.
219
219
220 You can read more about using :ref:`ipython qtconsole <qtconsole>`, and
220 You can read more about using :ref:`ipython qtconsole <qtconsole>`, and
221 :ref:`ipython notebook <htmlnotebook>`. There is also a :ref:`message spec
221 :ref:`ipython notebook <htmlnotebook>`. There is also a :ref:`message spec
222 <messaging>` which documents the protocol for communication between kernels
222 <messaging>` which documents the protocol for communication between kernels
223 and clients.
223 and clients.
224
224
225 .. seealso::
226
227 `Frontend/Kernel Model`_ example notebook
228
225
229
226 Interactive parallel computing
230 Interactive parallel computing
227 ==============================
231 ==============================
228
232
229 Increasingly, parallel computer hardware, such as multicore CPUs, clusters and
233 Increasingly, parallel computer hardware, such as multicore CPUs, clusters and
230 supercomputers, is becoming ubiquitous. Over the last several years, we have
234 supercomputers, is becoming ubiquitous. Over the last several years, we have
231 developed an architecture within IPython that allows such hardware to be used
235 developed an architecture within IPython that allows such hardware to be used
232 quickly and easily from Python. Moreover, this architecture is designed to
236 quickly and easily from Python. Moreover, this architecture is designed to
233 support interactive and collaborative parallel computing.
237 support interactive and collaborative parallel computing.
234
238
235 The main features of this system are:
239 The main features of this system are:
236
240
237 * Quickly parallelize Python code from an interactive Python/IPython session.
241 * Quickly parallelize Python code from an interactive Python/IPython session.
238
242
239 * A flexible and dynamic process model that be deployed on anything from
243 * A flexible and dynamic process model that be deployed on anything from
240 multicore workstations to supercomputers.
244 multicore workstations to supercomputers.
241
245
242 * An architecture that supports many different styles of parallelism, from
246 * An architecture that supports many different styles of parallelism, from
243 message passing to task farming. And all of these styles can be handled
247 message passing to task farming. And all of these styles can be handled
244 interactively.
248 interactively.
245
249
246 * Both blocking and fully asynchronous interfaces.
250 * Both blocking and fully asynchronous interfaces.
247
251
248 * High level APIs that enable many things to be parallelized in a few lines
252 * High level APIs that enable many things to be parallelized in a few lines
249 of code.
253 of code.
250
254
251 * Write parallel code that will run unchanged on everything from multicore
255 * Write parallel code that will run unchanged on everything from multicore
252 workstations to supercomputers.
256 workstations to supercomputers.
253
257
254 * Full integration with Message Passing libraries (MPI).
258 * Full integration with Message Passing libraries (MPI).
255
259
256 * Capabilities based security model with full encryption of network connections.
260 * Capabilities based security model with full encryption of network connections.
257
261
258 * Share live parallel jobs with other users securely. We call this
262 * Share live parallel jobs with other users securely. We call this
259 collaborative parallel computing.
263 collaborative parallel computing.
260
264
261 * Dynamically load balanced task farming system.
265 * Dynamically load balanced task farming system.
262
266
263 * Robust error handling. Python exceptions raised in parallel execution are
267 * Robust error handling. Python exceptions raised in parallel execution are
264 gathered and presented to the top-level code.
268 gathered and presented to the top-level code.
265
269
266 For more information, see our :ref:`overview <parallel_index>` of using IPython
270 For more information, see our :ref:`overview <parallel_index>` of using IPython
267 for parallel computing.
271 for parallel computing.
268
272
269 Portability and Python requirements
273 Portability and Python requirements
270 -----------------------------------
274 -----------------------------------
271
275
272 As of the 1.0 release, IPython works with Python 2.6, 2.7, 3.2 and 3.3.
276 As of the 1.0 release, IPython works with Python 2.6, 2.7, 3.2 and 3.3.
273 Version 0.12 introduced full support for Python 3. Version 0.11 worked with
277 Version 0.12 introduced full support for Python 3. Version 0.11 worked with
274 Python 2.6 and 2.7 only. Versions 0.9 and 0.10 worked with Python 2.4 and
278 Python 2.6 and 2.7 only. Versions 0.9 and 0.10 worked with Python 2.4 and
275 above (not including Python 3).
279 above (not including Python 3).
276
280
277 IPython is known to work on the following operating systems:
281 IPython is known to work on the following operating systems:
278
282
279 * Linux
283 * Linux
280 * Most other Unix-like OSs (AIX, Solaris, BSD, etc.)
284 * Most other Unix-like OSs (AIX, Solaris, BSD, etc.)
281 * Mac OS X
285 * Mac OS X
282 * Windows (CygWin, XP, Vista, etc.)
286 * Windows (CygWin, XP, Vista, etc.)
283
287
284 See :ref:`here <install_index>` for instructions on how to install IPython.
288 See :ref:`here <install_index>` for instructions on how to install IPython.
285
289
290 .. include:: links.txt
General Comments 0
You need to be logged in to leave comments. Login now