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!

Essential Cygwin Development Packages

Whenever I want to do a new Cygwin install on Windows, I’d have to just keep scrolling the Cygwin installer window to find the packages that I use frequently. I decided to compile a list of packages I use and put them here so that I wouldn’t have to waste time on it again in the future.

  • Devel:
    1. cmake
    2. cmake-gui
    3. gcc-core
    4. gcc-g++
    5. gdb
    6. git
    7. make
  • Libs:
    1. libboost-devel
  • Python:
    1. python3
  • Shells:
    1. chere (for shell integration)
  • X11: (Needed for cmake-gui)
    1. gnu-free-fonts
    2. xinit

Additionally, I let Cygwin’s installer to auto-install additional required packages. These packages should be sufficient for compiling C/C++ code under Windows. In order to enable shell integration for bringing up a Cygwin terminal, this command should be executed from Cygwin terminal (using administrator privileges) after installation:

chere -i -t mintty

“sys/time.h” Replacement for Windows

Some C/C++ code targeted for GNU family compilers fail to compile under Windows due to the dependency on sys/time.h header file. The repository here has provided a neat implementation for it. Basically you need these three files: time.h, times.h and times.cpp. I have included them here (in case the repository ever went dead). Note that this is not my code and the original license of the code was LGPL.