以下是here所述的安装内容:
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
接下来我想编译并安装Boost.NumPy。一开始,无法找到NumPy模块。经过一些搜索后,我在~/anaconda3/lib/python3.5/site-packages/numpy/core/include/numpy
中找到了与NumPy相关的文件,而不是/usr/lib
,/usr/local/lib
等等。因此,在/Boost.NumPy/CMakeList.txt
中,我添加了这一行:
set(NUMPY_INCLUDE_DIRS, /home/graphics/anaconda3/lib/python3.5/site-packages)
但NumPy仍然无法找到。运行cmake -DPYTHON_LIBRARY=$HOME/anaconda3/lib/libpython3.5m.so ../
生成Boost.NumPy的makefile时发生错误。这是错误:
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!
我试图将NUMPY_INCLUDE_DIRS
替换为其他目录,但没有任何效果。我应该写什么CMakelists.txt
告诉cmake在哪里找到NumPy模块并导入它?
提前致谢!
可能需要的其他文件来找出问题所在:
答案 0 :(得分:0)
最后它有效!但我不知道为什么...... :(
我做了什么:
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
希望这些可以帮助别人。