- Details
- Category: iPython
- Hits: 11175
{article Python Content}{title} {text} {/article}
iPython Example
Starting pylab | %logstart | %logoff | ipython notebook |
ipython notebook --pylab | ipython notebook --pylab inline |
||
Python Table of Content |
- Details
- Category: iPython
- Hits: 745
{article iPython Example}{title} {text} {/article}
quit() or Ctrl + D quits the IPython shell.
Using in cmd
{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
C:\Program Files>ipython -pylab
WARNING: `-pylab` flag has been deprecated.
Use `--matplotlib <backend>` and import pylab manually.
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 2.3.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
Using matplotlib backend: TkAgg
In [1]: quit()
C:\Program Files>
</pre>
<script language="javascript" type="text/javascript">
// You can place JavaScript like this
</script>
<?php
// You can place PHP like this
?>
{/source}
Using PowerShell
{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
PS C:\Users\Tom> ipython -pylab
WARNING: `-pylab` flag has been deprecated.
Use `--matplotlib <backend>` and import pylab manually.
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 2.3.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
Using matplotlib backend: TkAgg
In [1]: quit()
PS C:\Users\Tom>
</pre>
<script language="javascript" type="text/javascript">
// You can place JavaScript like this
</script>
<?php
// You can place PHP like this
?>
{/source}
Using Git
{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
Tom@TOM-GATEWAYPC ~/Web-Project/GitHub/git-project (master)
$ ipython -pylab
WARNING: `-pylab` flag has been deprecated.
Use `--matplotlib <backend>` and import pylab manually.
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 2.3.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
Using matplotlib backend: TkAgg
In [1]: quit()
Tom@TOM-GATEWAYPC ~/Web-Project/GitHub/git-project (master)
$
</pre>
<script language="javascript" type="text/javascript">
// You can place JavaScript like this
</script>
<?php
// You can place PHP like this
?>
{/source}
- Details
- Category: iPython
- Hits: 645
{article iPython Example}{title} {text} {/article}
Saving a session:
%logstart
{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
In [1]: %logstart
Activating auto-logging. Current session state plus future input saved.
Filename : ipython_log.py
Mode : rotate
Output logging : False
Raw input log : False
Timestamping : False
State : active
In [2]:
</pre>
<script language="javascript" type="text/javascript">
// You can place JavaScript like this
</script>
<?php
// You can place PHP like this
?>
{/source}
- Details
- Category: iPython
- Hits: 610
{article iPython Example}{title} {text} {/article}
%logoff
switched off as follows
{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
In [2]: %logoff
Switching logging OFF
In [3]:
</pre>
<script language="javascript" type="text/javascript">
// You can place JavaScript like this
</script>
<?php
// You can place PHP like this
?>
{/source}
- Details
- Category: iPython
- Hits: 771
{article iPython Example}{title} {text} {/article}
Starting a notebook with the following code:
ipython notebook
The notebook is opened in your default browser
{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
PS C:\Users\Tom> ipython notebook
2014-10-28 14:05:57.151 [NotebookApp] Using existing profile dir: 'C:\\emacs\\.ipython\\profile_default'
2014-10-28 14:05:57.198 [NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-10-28 14:05:57.385 [NotebookApp] Serving notebooks from local directory: C:\Users\Tom
2014-10-28 14:05:57.385 [NotebookApp] 0 active kernels
2014-10-28 14:05:57.385 [NotebookApp] The IPython Notebook is running at: http://localhost:8888/
2014-10-28 14:05:57.385 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirm
ation).
</pre>
<script language="javascript" type="text/javascript">
// You can place JavaScript like this
</script>
<?php
// You can place PHP like this
?>
{/source}
- Details
- Category: iPython
- Hits: 686
{article iPython Example}{title} {text} {/article}
Starting a notebook with the following code:
ipython notebook --pylab
This loads the Scipy, NumPy, and Matplotlib modules.
The notebook is opened in your default browser
{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
PS C:\Users\Tom> ipython notebook --pylab
2014-10-28 14:30:59.300 [NotebookApp] Using existing profile dir: 'C:\\emacs\\.ipython\\profile_default'
2014-10-28 14:30:59.300 [NotebookApp] WARNING | Starting all kernels in pylab mode is not recommended,
and will be disabled in a future release.
Please use the %matplotlib magic to enable matplotlib instead.
pylab implies many imports, which can have confusing side effects
and harm the reproducibility of your notebooks.
2014-10-28 14:30:59.347 [NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-10-28 14:30:59.440 [NotebookApp] Serving notebooks from local directory: C:\Users\Tom
2014-10-28 14:30:59.440 [NotebookApp] 0 active kernels
2014-10-28 14:30:59.440 [NotebookApp] The IPython Notebook is running at: http://localhost:8888/
2014-10-28 14:30:59.440 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirm
ation).
</pre>
<script language="javascript" type="text/javascript">
// You can place JavaScript like this
</script>
<?php
// You can place PHP like this
?>
{/source}
- Details
- Category: iPython
- Hits: 705
{article iPython Example}{title} {text} {/article}
ipython notebook --pylab inline
Display inline Matplotlib plots with the inline directive, using the following command:
{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
PS C:\Users\Tom> ipython notebook --pylab inline
2014-10-28 14:40:29.267 [NotebookApp] Using existing profile dir: 'C:\\emacs\\.ipython\\profile_default'
2014-10-28 14:40:29.269 [NotebookApp] WARNING | Starting all kernels in pylab mode is not recommended,
and will be disabled in a future release.
Please use the %matplotlib magic to enable matplotlib instead.
pylab implies many imports, which can have confusing side effects
and harm the reproducibility of your notebooks.
2014-10-28 14:40:29.309 [NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-10-28 14:40:29.406 [NotebookApp] Serving notebooks from local directory: C:\Users\Tom
2014-10-28 14:40:29.406 [NotebookApp] 0 active kernels
2014-10-28 14:40:29.406 [NotebookApp] The IPython Notebook is running at: http://localhost:8888/
2014-10-28 14:40:29.407 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirm
ation).
</pre>
<script language="javascript" type="text/javascript">
// You can place JavaScript like this
</script>
<?php
// You can place PHP like this
?>
{/source}
1. Create a notebook: Click on the New Notebook button to create a new notebook:
2. Create an array: Create an array with the arange function. Type the command in the following screenshot, and press Enter:
a = arange(7)
3. Next, enter the following command and press Enter
a