Fixing missing python headers in MacOS 10.13 High Sierra

While compiling my favorite C++ Programs, I encountered a bug which is likely related to the recent 10.13 High Sierra update and the change to XCode command line tools.

fatal error: 'Python.h' file not found
#include "Python.h"
1 error generated.

Many programs will still include python headers with the g++/clang++ flag -I/System/Library/Frameworks/Python.framework/Versions/2.7/Headers, however it's apparent that with command line tools 9.1 this is no longer a directory.

The header files are now at /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/.

In order to fix the error without changing your build, you can symlink them:

The fix:

sudo mkdir /System/Library/Frameworks/Python.framework/Versions/2.7/Headers

sudo chown -R $(whoami) /System/Library/Frameworks/Python.framework/Versions/2.7/Headers

ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/* /System/Library/Frameworks/Python.framework/Versions/2.7/Headers/

Note that this does require SIP to be disabled (how to here). If you would rather not turn it off, I recommend changing/adding the header include path to /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/.