So if you experienced this awkward situation that you are trying to install a python package that is dependent on numpy but you receive an error from clang complaining about not being to find numpy header files this might be your quick solution.
This kind of problems happen far too often on Mac than you’d be comfortable with. I mean as a nerd I expect some challenge but common this kind is more a waste of time. Basically I was seeing this error while trying to install javabrdige on mac for python3.7:
1 2 3 4 |
#include "numpy/arrayobject.h" ^ 1 error generated. error: command 'clang' failed with exit status |
Obviously this is due to the fact that clang can’t find numpy headers on its path. A simple workaround is to temporary add the directory to it. You can find where your header files are stored at using
1 2 3 |
>>>import numpy as np >>> np.get_include() '/Users/Salim/Library/Python/3.7/lib/python/site-packages/numpy/core/include' |
And finally you can add it to the classpath for clang using the following command:
1 |
export CFLAGS="-I/Users/Salim/Library/Python/3.7/lib/python/site-packages/numpy/core/include $CFLAGS" |
I hope if you head into the same problem you can find this post quickly and save up some time