mattjj / pyhsmm

MIT License
546 stars 173 forks source link

Cannot build in place on Mac OS X #46

Closed mathDR closed 9 years ago

mathDR commented 9 years ago

So currently both pip install pyhsmm breaks and attempting to manually build via python setup.py build_ext --inplace --with-cython breaks with the same error:

pyhsmm/internals/hmm_messages_interface.cpp:271:10: fatal error: 'numpy/arrayobject.h' file not found

There are other examples of this online (i.e. it is apparently due to cython compiler not finding the numpy header files)

Have you successfully compiled on mac?

mattjj commented 9 years ago

Yeah; actually my main development machine is a mac.

It sounds like there may be a problem with your python setup. Are you able to build other cython code that uses numpy (via cimport numpy)?

Things to check:

If you're not already using anaconda or miniconda, now might be a good time to give those a shot.

mattjj commented 9 years ago

Here's a small test to see if cython is able to build things:

Put this in foo.pyx:

import numpy as np
cimport numpy as np

def foo(double[:] a, double[:] b):
    return np.dot(a,b)

Put this in setup.py:

from distutils.core import setup
import numpy as np
from Cython.Build import cythonize

setup(ext_modules=cythonize('*.pyx'), include_dirs=[np.get_include()])

I checked that the generated foo.c includes numpy/arrayobject.h and that things build (and run correctly) with python setup.py build_ext --inplace.

mathDR commented 9 years ago

Thanks, yep your example didn't work on my machine. Interesting. I used to be able to compile, but for some reason it doesn't work now. Maybe homebrew did something, but I will close this as it is definitely my environment.

mathDR commented 9 years ago

Just a heads up: if I change from: distutils.core import setup to: from numpy.distutils.core import setup

everything works. This seems super crazy. Apparently with disutils, the default clang couldn't see the numpy header files? Strange...