pystruct / pystruct

Simple structured learning framework for python
http://pystruct.github.io
BSD 2-Clause "Simplified" License
664 stars 172 forks source link

Installation error on OSX El Capitan (with suggested fix/workaround) #181

Closed HannesHolste closed 8 years ago

HannesHolste commented 8 years ago

On OSX El Capitan 10.11.3, with pip + scikit-learn + numpy + python, running

pip install pystruct throws this error (shortened):

  clang -bundle -undefined dynamic_lookup build/temp.macosx-10.10-x86_64-2.7/src/utils.o -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/sqlite/lib -o build/lib.macosx-10.10-x86_64-2.7/pystruct/models/utils.so
    building 'pystruct.inference._viterbi' extension
    creating build/temp.macosx-10.10-x86_64-2.7/pystruct
    creating build/temp.macosx-10.10-x86_64-2.7/pystruct/inference
    clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pystruct/inference/_viterbi.c -o build/temp.macosx-10.10-x86_64-2.7/pystruct/inference/_viterbi.o
    pystruct/inference/_viterbi.c:239:10: fatal error: 'numpy/arrayobject.h' file not found
    #include "numpy/arrayobject.h"
             ^
    1 error generated.
    error: command 'clang' failed with exit status 1

    ----------------------------------------
Command "/usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/7b/hxdy_2vj1_zfvs85yt0fpnnh0000gn/T/pip-build-34XlrC/pystruct/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/7b/hxdy_2vj1_zfvs85yt0fpnnh0000gn/T/pip-hC5F8f-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/7b/hxdy_2vj1_zfvs85yt0fpnnh0000gn/T/pip-build-34XlrC/pystruct/

I fixed it by running this in console, to include numpy/core/include in the clang build procedure: export CFLAGS="-I /usr/local/lib/python2.7/site-packages/numpy/core/include $CFLAGS" and then re-running: pip install pystruct

Related discussion on this problem from another package: https://github.com/esheldon/fitsio/issues/49

amueller commented 8 years ago

Thanks for the report and sorry for the slow reply. Could you please check what "numpy.get_include()" produces on your system?

Thanks!

amueller commented 8 years ago

Or rather: can you check if #182 fixes the issue for you?

HannesHolste commented 8 years ago

Yes, #182 fixes the error. To test that PR, I removed the $CFLAGS modification, uninstalled pystruct via pip, checked out the pull request locally, and successfully ran make as well as pip install -e ./local-pystruct/.

Danke, Andreas!

>>> import numpy
>>> numpy.get_include()
'/usr/local/lib/python2.7/site-packages/numpy/core/include'