Book Image

NumPy Cookbook - Second Edition

By : Ivan Idris
Book Image

NumPy Cookbook - Second Edition

By: Ivan Idris

Overview of this book

<p>NumPy has the ability to give you speed and high productivity. High performance calculations can be done easily with clean and efficient code, and it allows you to execute complex algebraic and mathematical computations in no time.</p> <p>This book will give you a solid foundation in NumPy arrays and universal functions. Starting with the installation and configuration of IPython, you'll learn about advanced indexing and array concepts along with commonly used yet effective functions. You will then cover practical concepts such as image processing, special arrays, and universal functions. You will also learn about plotting with Matplotlib and the related SciPy project with the help of examples. At the end of the book, you will study how to explore atmospheric pressure and its related techniques. By the time you finish this book, you'll be able to write clean and fast code with NumPy.</p>
Table of Contents (19 chapters)
NumPy Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Installing IPython


IPython can be installed in various ways, depending on your operating system. For the terminal-based shell, there is a dependency on readline. The web notebook requires tornado and zmq.

In addition to installing IPython, we will install setuptools, which gives you the easy_install command. The easy_install command is a popular package manager for Python. pip can be installed once you have easy_install. The pip command is similar to easy_install and adds options such as uninstalling.

How to do it...

This section describes how IPython can be installed on Windows, Mac OS X, and Linux. It also describes how to install IPython and its dependencies with easy_install and pip, or from source:

  • Installing IPython and setuptools on Windows: A binary Windows installer for Python 2 or Python 3 is available on the IPython website. Also see http://ipython.org/ipython-doc/stable/install/install.html#windows.

    Install setuptools with an installer from http://pypi.python.org/pypi/setuptools#files. Then install pip, like this:

    cd C:\Python27\scripts
    python .\easy_install-27-script.py pip
    
  • Installing IPython on Mac OS X: Install the Apple Developer Tools (Xcode) if necessary. Xcode can be found at https://developer.apple.com/xcode/. Follow the easy_install/pip instructions or the instructions for installation from source provided later in this section.

  • Installing IPython on Linux: Since there are so many Linux distributions, this section will not be exhaustive:

    • On Debian, type the following command:

      $ su – aptitude install ipython python-setuptools
      
    • On Fedora, the magic command is as follows:

      $ su – yum install ipython python-setuptools-devel
      
    • The following command will install IPython on Gentoo:

      $ su – emerge ipython
      
    • For Ubuntu, the install command is as follows:

      $ sudo apt-get install ipython python-setuptools
      
  • Installing IPython with easy_install or pip: Install IPython and all the dependencies required for the recipes in this chapter with easy_install using the following command:

    $ sudo easy_install ipython pyzmq tornado readline
    

    Alternatively, you can first install pip with easy_install by typing this command in your terminal:

    $ sudo easy_install pip
    

    After that, install IPython using pip:

    $ sudo pip install ipython pyzmq tornado readline
    
  • Installing from source: If you want to use the bleeding-edge development version, then installing from source is for you:

    1. Download the latest source archive from https://github.com/ipython/ipython/archive/master.zip.

    2. Unpack the source code from the archive:

      $ tar xzf ipython-<version>.tar.gz
      
    3. Instead, if you have Git installed, you can clone the Git repository:

      $ git clone https://github.com/ipython/ipython.git
      
    4. Go to the root directory within the downloaded source:

      $ cd ipython
      
    5. Run the setup script. This may require you to run the command with sudo, as follows:

      $ sudo python setup.py install
      

How it works...

We installed IPython using several methods. Most of these methods install the latest stable release, except when you install from source, which will install the development version.

See also