CMake Error "NumPy import failure" when compiling Boost.Numpy
Question: Here is what I installed as described [here](https://github.com/mitmul/ssai-
cnn):

    
    
    1. Python 3.5 (Anaconda3 2.4.3)
        Chainer 1.5.0.2
        Cython 0.23.4
        NumPy 1.10.1
        tqdm
    2. OpenCV 3.0.0
    3. lmdb 0.87
    4. Boost 1.59.0
    

Next I want to compile and install Boost.NumPy. In the beginning, NumPy module
could not be found. After some search, I found NumPy-related files in
`~/anaconda3/lib/python3.5/site-packages/numpy/core/include/numpy` instead of
something like `/usr/lib`, `/usr/local/lib`, etc. Therefore, in
`/Boost.NumPy/CMakeList.txt`, I added this line:

    
    
    set(NUMPY_INCLUDE_DIRS, /home/graphics/anaconda3/lib/python3.5/site-packages)
    

But NumPy still could not be found. An error occurred as I run `cmake
-DPYTHON_LIBRARY=$HOME/anaconda3/lib/libpython3.5m.so ../` to generate the
makefile for Boost.NumPy. Here is the error:

    
    
    graphics@gubuntu:~/usr/Boost.NumPy/build$ sudo cmake -DPYTHON_LIBRARY=$HOME/anaconda3/lib/libpython3.5m.so ../
    -- The C compiler identification is GNU 4.9.2
    -- The CXX compiler identification is GNU 4.9.2
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Found PythonInterp: /usr/bin/python3.5 (found suitable version "3.5.1", minimum required is "3.5") 
    -- Found PythonInterp: /usr/bin/python3.5 (found version "3.5.1") 
    -- Found PythonLibs: /home/graphics/anaconda3/lib/libpython3.5m.so
    CMake Error at libs/numpy/cmake/FindNumPy.cmake:61 (message):
      NumPy import failure:
    
      Traceback (most recent call last):
    
        File "<string>", line 1, in <module>
    
      ImportError: No module named 'numpy'
    
    Call Stack (most recent call first):
      CMakeLists.txt:30 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    

I have tried to replace `NUMPY_INCLUDE_DIRS` with some other directories, but
nothing works. What should I write to the `CMakelists.txt` to tell cmake where
to find NumPy module and import it?

Thanks in advance!

* * *

Others files which might be needed to find out what goes wrong:

  1. [CMakeLists.txt](http://example.haichaoyu.com/example/CMakeLists.txt) of Boost.NumPy.


Answer: Finally it works! But I don't know why...:(

What I did:

    
    
    1.  I reinstalled numpy to /usr/lib/python3.5/site-packages (previously, I installed it to ~/anaconda3/lib/python3.4/site-packages)
    1.1 I also added ~/anaconda3/lib/python3.4/site-packages/numpy/include to $PYTHONPATH and $PATH
    2.  I ran these commands in Python:
       >>>import numpy 
       And I found it returns no error!
    3.  I removed previously compiled files in directory build, and rebuilt. Finally it worked
    

Hope these helps someone else.

