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:
[/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:
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 |
[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:
$ yum install python-numpy
$ urpmi python-numpy
$ sudo emerge numpy
$ 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:
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.
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.