pythonmacoscouchapp

fatal error: 'Python/Python.h' file not found while installing couchapp


I am trying to install couchapp from the terminal on macOs High Sierra.

I have python 2.7.10 installed (by default) and I run $ pip2 install couchapp according to the couchapp documentation.

This is the error I get:

src/watchdog_fsevents.c:22:10: fatal error: 'Python/Python.h' file not found
    #include <Python/Python.h>
             ^~~~~~~~~~~~~~~~~
    1 error generated.
    error: command 'cc' failed with exit status 1

 ----------------------------------------
  Failed building wheel for watchdog

Here is what I have when I do $ ls in /System/Library/Frameworks/Python.framework/


What I have tried so far:

  1. Check that Xcode CL Tools are already installed running $ xcode-select --install
  2. Try to use pip3 instead of pip2 (I have installed python 3.6 with Homebrew), but I get the same error message.

Do you have any idea? I have read other posts but they did not solve my problem.

Thank you


Solution

  • Had a very similar problem on my High Sierra (10.13.5) setup with Xcode CLI tools installed; for me the Python.h was found in /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7

    (Some resources say the location can be found via find /usr/local/Cellar/ -name Python.h, however this seems not work if your python was not installed with brew.)

    Add the location to your C include path, or at compile time as a flag by setting -I flag as such: -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7.

    The part that tripped me up was the import statement should then look like: #include <Python.h> rather than #include <Python/Python.h> if your Python.h is directly in the python2.7 directory.

    Hope that helps,