27

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

python setup.py 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.

Rickkwa
  • 2,197
  • 4
  • 23
  • 34

3 Answers3

54

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.
Zeus
  • 6,386
  • 6
  • 54
  • 89
Matt Cecil
  • 556
  • 5
  • 2
  • 16
    In the search may be called python2-devel or python3-devel, depending on the python version you are working with. – bvanlew Apr 14 '17 at 12:50
  • Solved my problem. It would be great if you can add @bvanlew's suggestion. – vikbehal Sep 04 '17 at 22:50
  • It seems like this answer is marked as "accepted" but it doesn't directly solve the problem. I am currently searching for solution to my build problem where I try to compile uWSGI using Cygwin. I have all of the python-devel packages installed and Python.h files are indeed inside /usr/include/. – Kaszanas May 21 '20 at 15:34
  • 1
    For later versions, make sure to select the appropriate package, e.g. `python37-devel` or `python38-devel`. – Anakhand Sep 29 '20 at 22:53
3

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
  • 2
    In my case, I didn't have a cygwin GCC installed at all, just the MinGW one. One wonders how I survived up to this point. – Reid Rankin Sep 14 '15 at 16:06
0

This looks similar to the following discussion on ubuntu forums:

http://ubuntuforums.org/archive/index.php/t-2136273.html

one of the solutions is to "sudo apt-get build-dep python-matplotlib", while other solution is to check whether you are compiling with correct python. Python 2 uses MPL < 1.2 and python 3 MPL >= 1.2.

Madhu
  • 17
  • 1