From charlesreid1

Py4Sci is a handy Python package consisting of four pieces: iPython (extends the python shell to behave more like Bash or Csh), Numpy (extends the numerical capabilities of Python to be something more akin to Matlab), Scipy (provides functionality geared toward scientific/engineering applications), and Matplotlib (gives Python plotting capabilities).

The whole purpose of Py4Sci (a.k.a. Pylab) is to provide a free (as in speech, not as in beer) Python analog to Matlab. This is also extremely handy if you're dealing with a Python package like Cantera that is inherently numerical and requires plotting capabilities. (take a look at the bottom of the Using_Cantera#Python page for an example of the quality plots you can create with Matplotlib).

Official links to projects:

Installation

Linux

This is very straightforward, given that most every distribution's package manager has the above 4 Python extensions (in fact, many distributions already have at least some of the above packages, esp. iPython). Use the following commands for Debian-based distributions (e.g. Ubuntu):

$ apt-get install ipython
$ apt-get install numpy
$ apt-get install scipy
$ apt-get install matplotlib

where one may replace "apt-get" with the appropriate package manager (e.g. "yum" for Fedora).

Mac

This is a very easy and streamlined process that was was formerly (2008 or so) extremely difficult and frustrating. Yay!

In most cases, you can either install the binary version, or you can install Python packages from source using a three-step process.

The first step is to build the package:

$ python ./setup.py build

The second step is to install the package. This is where you would specify a prefix if you don't want the package to be installed system-wide:

$ python ./setup.py install

or

$ python ./setup.py install --prefix=/path/to/package

The third and final step is to add /path/to/package to your $PYTHONPATH variable. The location of the necessary Python stuff can be found by tacking on a lib/python2.7/site-packages/ to the end of /path/to/package.

You can always check this location and make sure there is a directory in site-packages with the name of the package you want to use. For example, if I wanted to use the numpy package from Python by issuing the Python command from numpy import *, then I would check there is a directory named numpy in the site-packages for the numpy installation location... etc...

So in the example I gave, you would add the following path to your $PYTHONPATH variable:

export PYTHONPATH="/path/to/package/lib/python2.7/sitepackages:${PYTHONPATH}"

This would go in one of your Dot files, like .profile or .bashrc.

Leopard (OS X 10.5)

The binary installation process worked fine on Mac Leopard.


Snow Leopard (OS X 10.6)

On Snow Leopard, the straightforward steps presented on the "Installing Scipy and Numpy" page didn't work out so great.

I ended up installing the Scipy and Numpy packages from source, and adding their locations to $PYTHONPATH by hand.

Windows

The instructions here are very straightforward... Binary installers should work just fine.

SciPy and NumPy installation instructions here: http://www.scipy.org/Installing_SciPy/Windows

Matplotlib installation can be done using the Windows binary, available here: http://sourceforge.net/projects/matplotlib/

iPython installation is also easy, using the Windows binary provided here: http://ipython.scipy.org/moin/Download

References