CANCEL

Subscription

0

Your Cart
(0 item)

You have no products in your basket yet

Save more on your purchases now!

Savings automatically calculated. No voucher code required.

Account

- 7 min read
- 12 Oct 2014

This article written by **Ivan Idris**, author of the book, Python Data Analysis, will guide you to install NumPy, SciPy, matplotlib, and IPython.

We can find a mind map describing software that can be used for data analysis at https://www.xmind.net/m/WvfC/. Obviously, we can't install all of this software in this article. We will install **NumPy**, **SciPy**, **matplotlib**, and **IPython** on different operating systems.

[box type="info" align="" class="" width=""]Packt has the following books that are focused on NumPy:

*NumPy Beginner's Guide Second Edition*,*Ivan Idris**NumPy Cookbook*,*Ivan Idris**Learning NumPy Array, Ivan Idris*

[/box]

**SciPy** is a scientific Python library, which supplements and slightly overlaps NumPy. NumPy and SciPy, historically shared their codebase but were later separated.

**matplotlib** is a plotting library based on NumPy.

**IPython** provides an architecture for interactive computing. The most notable part of this project is the IPython shell.

The software used in this article is based on Python, so it is required to have Python installed. On some operating systems, Python is already installed. You, however, need to check whether the Python version is compatible with the software version you want to install. There are many implementations of Python, including commercial implementations and distributions.

[box type="note" align="" class="" width=""]You can download Python from https://www.python.org/download/. On this website, we can find installers for Windows and Mac OS X, as well as source archives for Linux, Unix, and Mac OS X.[/box]

The software we will install has binary installers for Windows, various Linux distributions, and Mac OS X. There are also source distributions, if you prefer that. You need to have Python 2.4.x or above installed on your system. Python 2.7.x is currently the best Python version to have because most Scientific Python libraries support it. Python 2.7 will be supported and maintained until 2020. After that, we will have to switch to Python 3.

Installing on Windows is, fortunately, a straightforward task that we will cover in detail. You only need to download an installer, and a wizard will guide you through the installation steps. We will give steps to install NumPy here. The steps to install the other libraries are similar. The actions we will take are as follows:

- Download installers for Windows from the SourceForge website (refer to the following table). The latest release versions may change, so just choose the one that fits your setup best.

Library |
URL |
Latest Version |

NumPy | http://sourceforge.net/projects/numpy/files/ | 1.8.1 |

SciPy | http://sourceforge.net/projects/scipy/files/ | 0.14.0 |

matplotlib | http://sourceforge.net/projects/matplotlib/files/ | 1.3.1 |

IPython | http://archive.ipython.org/release/ | 2.0.0 |

- Choose the appropriate version. In this example, we chose
*numpy-1.8.1-win32-superpack-python2.7.exe*. - Open the EXE installer by double-clicking on it.
- Now, we can see a description of NumPy and its features. Click on the
**Next**button.If you have Python installed, it should automatically be detected. If it is not detected, maybe your path settings are wrong. - Click on the
**Next**button if Python is found; otherwise, click on the**Cancel**button and install Python (NumPy cannot be installed without Python). Click on the**Next**button. This is the point of no return. Well, kind of, but it is best to make sure that you are installing to the proper directory and so on and so forth. Now the real installation starts. This may take a while.

[box type="note" align="" class="" width=""]The situation around installers is rapidly evolving. Other alternatives exist in various stage of maturity (see https://www.scipy.org/install.html). It might be necessary to put the *msvcp71.dll* file in your *C:Windowssystem32* directory. You can get it from http://www.dll-files.com/dllindex/dll-files.shtml?msvcp71.[/box]

Installing the recommended software on Linux depends on the distribution you have. We will discuss how you would install NumPy from the command line, although, you could probably use graphical installers; it depends on your distribution (distro). The commands to install matplotlib, SciPy, and IPython are the same – only the package names are different. Installing matplotlib, SciPy, and IPython is recommended, but optional.

Most Linux distributions have NumPy packages. We will go through the necessary steps for some of the popular Linux distros:

- Run the following instructions from the command line for installing NumPy on Red Hat:
**$ yum install python-numpy** - To install NumPy on Mandriva, run the following command-line instruction:
**$ urpmi python-numpy** - To install NumPy on Gentoo run the following command-line instruction:
**$ sudo emerge numpy** - To install NumPy on Debian or Ubuntu, we need to type the following:
**$ sudo apt-get install python-numpy**

The following table gives an overview of the Linux distributions and corresponding package names for NumPy, SciPy, matplotlib, and IPython.

Linux distribution |
NumPy |
SciPy |
matplotlib |
IPython |

Arch Linux | python-numpy |
python-scipy |
python-matplotlib |
Ipython |

Debian | python-numpy |
python-scipy |
python-matplotlib |
Ipython |

Fedora | numpy |
python-scipy |
python-matplotlib |
Ipython |

Gentoo | dev-python/numpy |
scipy |
matplotlib |
ipython |

OpenSUSE | python-numpy, python-numpy-devel |
python-scipy |
python-matplotlib |
ipython |

Slackware | numpy |
scipy |
matplotlib |
ipython |

You can install NumPy, matplotlib, and SciPy on the Mac with a graphical installer or from the command line with a port manager such as MacPorts, depending on your preference. Prerequisite is to install XCode as it is not part of OS X releases. We will install NumPy with a GUI installer using the following steps:

- We can get a NumPy installer from the SourceForge website http://sourceforge.net/projects/numpy/files/. Similar files exist for matplotlib and SciPy.
- Just change
*numpy*in the previous URL to*scipy*or*matplotlib*. IPython didn't have a GUI installer at the time of writing. - Download the appropriate
*DMG*file usually the latest one is the best.Another alternative is the SciPy Superpack (https://github.com/fonnesbeck/ScipySuperpack).

Whichever option you choose it is important to make sure that updates which impact the system Python library don't negatively influence already installed software by not building against the Python library provided by Apple.

- Open the
**DMG file**(in this example,**numpy-1.8.1-py2.7-python.org-macosx10.6.dmg**). - Double-click on the icon of the opened box, the one having a subscript that ends with
*.mpkg*. We will be presented with the welcome screen of the installer. - Click on the
**Continue**button to go to the**Read****Me**screen, where we will be presented with a short description of NumPy. - Click on the
**Continue**button to the License the screen. - Read the license, click on the
**Continue**button and then on the**Accept**button, when prompted to accept the license. Continue through the next screens and click on the**Finish**button at the end.

Alternatively, we can install NumPy, SciPy, matplotlib, and IPython through the MacPorts route, with Fink or Homebrew. The following installation steps shown, installs all these packages.

[box type="info" align="" class="" width=""]For installing with MacPorts, type the following command:

sudo port install py-numpy py-scipy py-matplotlib py-ipython

[/box]

If you have *pip* you can install NumPy, SciPy, matplotlib and IPython with the following commands.

pip install numpy

**pip install scipy**

**pip install matplotlib**

**pip install ipython**

It may be necessary to prepend *sudo* to these commands, if your current user doesn't have sufficient rights on your system.

In this article, we installed NumPy, SciPy, matplotlib and IPython on Windows, Mac OS X and Linux.