Installing SciPy, NumPy and matplotlib Under Cygwin

Today I tried installing these modules under Cygwin with pip. The whole thing took a few hours to figure out thanks to crappy bundled packages that pip fetches and lack of consistency between helps available online.

To install pip, you need to have python3-setuptoolsinstalled. Then using the easy_install3 pip command you can install pip.

After that, you need to have liblapack-devel and libopenblas installed via Cygwin’s package manager (SciPy depends on them). You also need to have gcc-fortran, python-gtk2, tcl-tk, libpng, pkg-config and a bunch of other stuff (that pip installer complains about) installed. The dependencies that pip complains about are straightforward (just mark them for installation in Cygwin’s installer).

Running pip -v install numpy and pip -v install matplotlib should get you those packages without much headache. The most important thing is that as of SciPy v 0.16.1, there seems to be some error in SciPy’s C files that prevents compilation and installation. I was able to get it to install using pip -v install scipy==0.15.1.

After installation, you may notice that you can’t plot stuff using mathplotlib’s pyplot module. To fix that, you need to have XWinServer running and should configure matplotlib to use tkagg backend. To do this, locate the file matplotlibrc and change backend      : agg to backend      : tkagg. The plots should show now!