1

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/

  • Examples
  • Modules
  • Python
  • Resources
  • Versions
  • module.map

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

Sala
  • 335
  • 3
  • 17
  • What this generally always means is that you don't have Python development headers present. – Charles Duffy Mar 22 '18 at 20:36
  • Closely related to [What did Apple do to the Python framework?](https://stackoverflow.com/questions/6151548/what-did-apple-do-to-the-python-framework) – Charles Duffy Mar 22 '18 at 20:37
  • Install `python-dev` if not installed. Hopefully helps. – Sumit Jha Mar 22 '18 at 20:39
  • 1
    @SumitJha, there is no `python-dev` package for MacOS. Rather, there, these headers are included with XCode. – Charles Duffy Mar 22 '18 at 20:40
  • Ah yes. Then add `/System/Library/Frameworks/Python.framework/Versions/2.7/include/` to `$PATH` and maybe `brew reinstall python` could help. – Sumit Jha Mar 22 '18 at 20:43
  • Hello @SumitJha, I have tried to add/reinstall but it didn't work. I also tried to update Xcode but it is already up to date. – Sala Mar 23 '18 at 08:19
  • @Sala . ` 'Python/Python.h' file not found` typically means the compiler is not able to find the path. Do you know where your Python.h exist? [This](https://stackoverflow.com/questions/35778495/fatal-error-python-h-file-not-found-while-installing-opencv/35778751) might be helpful. – Sumit Jha Mar 23 '18 at 08:30
  • @SumitJha the path is `/System/Library/Frameworks/Python.framework/Versions/2.7/include/` ... Maybe that's Python3 doing the mess? – Sala Apr 11 '18 at 12:05

1 Answers1

1

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,

polymorphics
  • 136
  • 1
  • 3