I'm trying to compile C++ code for a Python3 extension on macOS, and I'm only able to compile if I #include "$HOME/anaconda3/include/python3.6m/Python.h. Is there a way to #include <Python/Python.h> and have the "include" refer to the anaconda Python.h instead of the system Python.h?
1 Answer
Having your Python.h inside a directory named python3.6m makes it a bit awkward, but here are two possible ways to resolve the issue:
Rename the directory from python3.6m to Python, and then add the argument
-I$HOME/anaconda3/includeto your compile line, to tell the compiler to resolve include-paths starting at that folder.Alternatively, you could add a symlink so that the python3.6m directory can be accessed via two different names, e.g.:
cd ~/anaconda3/include ; ln -s python3.6m Python
... and then add the argument -I$HOME/anaconda3/include to your compiler arguments (same as in step 1)