Cygwin gcc issue - cannot find Python.h


So I downloaded Cygwin to build Matplotlib on Windows. Upon running

python build

I get a message saying Python.h cannot be found (pastebin).

Looking in /usr/include/python2.7, I can clearly see Python.h exists.

When I do:

gcc -print-search-dirs

I get paths to some Haskell folder outside of the cygwin installation folder. Full output here.

2/18/2014 3:24:54 AM

Accepted Answer

in cygwin make sure the python-devel package is installed:

  • Run the cygwin installer (setup-x86(_64).exe
  • Click through until you get to the page to install packages
  • install the "python-devel" package from the "python" section. [Update from Comments] It is available as python2-devel or python3-devel under Python section for some.
1/18/2018 3:30:58 PM

I realize your question is old but I stumbled upon the exact same problem and found the solution so I thought I would share it. You probably have another gcc installed outside of cygwin, in my case it was a mingw-tdm native windows gcc variant. It happened to be in the path before the actual cygwin gcc, and was therefore picked up by the python installer.

To solve the problem, you only need to locate (or install) the cygwin gcc you need (either 32 or 64-bit), and do

export CC=/path/to/correct/gcc/exe

for instance

export CC=/usr/bin/x86_64-pc-cygwin-gcc

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow