I am trying to install Opencv 3.2.0 on Ubuntu 16.04 with Python 2.7 bindings. The Fabric script works perfectly when I install Opencv 3.1.0 in this way, but when I try 3.2.0 I receive the following error:
我正在尝试用Python 2.7绑定在Ubuntu 16.04上安装Opencv 3.2.0。当我以这种方式安装Opencv 3.1.0时,Fabric脚本工作得很好,但是当我尝试3.2.0时,我收到了以下错误:
[ 83%] Building CXX object modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o
In file included from /srv/envs/anim8/local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:4:0, from /srv/envs/anim8/local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18, from /root/opencv-3.2.0/modules/python/src2/cv2.cpp:10: /srv/envs/anim8/local/lib/python2.7/site-packages/numpy/core/include/numpy/npy_common.h:17:5: warning: "NPY_INTERNAL_BUILD" is not defined [-Wundef]
#if NPY_INTERNAL_BUILD
^
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
modules/python2/CMakeFiles/opencv_python2.dir/build.make:320: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o' failed
make[2]: ***
[modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o] Error 4
CMakeFiles/Makefile2:20394: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/all' failed
make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
I am using a Fabric script, I have included the relevant section below:
我正在使用一个面料的脚本,我已经把相关的部分包括在下面:
cv_ver = '3.2.0'
sudo('apt-get install -y build-essential cmake pkg-config')
sudo('apt-get install -y python-pip python-dev libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev zlib1g-dev')
sudo('apt-get install -y zip unzip')
sudo('apt-get install -y libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev')
sudo('apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev')
sudo('apt-get install -y libxvidcore-dev libx264-dev')
sudo('sudo apt-get install -y libgtk-3-dev')
sudo('apt-get install -y libatlas-base-dev gfortran')
sudo('apt-get install -y python2.7-dev python3.5-dev')
with cd('~/'):
run('wget -O opencv.zip https://github.com/Itseez/opencv/archive/{cv_ver}.zip'.format(cv_ver=cv_ver))
run('unzip opencv.zip')
run('wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/{cv_ver}.zip'.format(cv_ver=cv_ver))
run('unzip opencv_contrib.zip')
with cd('~/opencv-{cv_ver}/'.format(cv_ver=cv_ver)):
run('mkdir build')
with cd('~/opencv-{cv_ver}/build/'.format(cv_ver=cv_ver)):
run('pip install numpy')
run('cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-{cv_ver}/modules \
-D PYTHON_EXECUTABLE={venv}/bin/python \
-D BUILD_EXAMPLES=ON ..'.format(
venv=configuration.VIRTUALENV_PATH,
cv_ver=cv_ver)
)
run('make')
sudo('make install')
sudo('ldconfig')
Any help would be greatly appriciated.
任何帮助都将非常昂贵。
2 个解决方案
#1
3
First of all change the directory to "/srv/envs/anim8/local/lib/python2.7/site-packages/numpy/core/include/numpy"
首先,将目录更改为“/srv/env /anim8/local/lib/python2.7/site-package /numpy/core/include/numpy”
Then use ls
command.
然后使用ls命令。
open file npy_common.h
and change the line
npy_common打开文件。改变直线。
#if NPY_INTERNAL_BUILD
to #ifndef NPY_INTERNAL_BUILD
如果NPY_INTERNAL_BUILD到#ifndef NPY_INTERNAL_BUILD。
write following command
下面写命令
#define NPY_INTERNAL_BUILD
just after #ifndef NPY_INTERNAL_BUILD
#定义NPY_INTERNAL_BUILD在#ifndef NPY_INTERNAL_BUILD之后。
#2
0
Atul answer helped me, but it was only part of solution. I got fatal error: hdf5.h: No such file or directory
.
阿图尔的回答帮助了我,但这只是解决方案的一部分。我犯了致命错误:hdf5。h:没有这样的文件或目录。
To solve this add:
为了解决这个添加:
find_package(HDF5) include_directories(${HDF5_INCLUDE_DIRS})
find_package(HDF5)include_directories($ { HDF5_INCLUDE_DIRS })
at the end of modules/python/common.cmake file.
在模块/python/common的末尾。cmake文件。
#1
3
First of all change the directory to "/srv/envs/anim8/local/lib/python2.7/site-packages/numpy/core/include/numpy"
首先,将目录更改为“/srv/env /anim8/local/lib/python2.7/site-package /numpy/core/include/numpy”
Then use ls
command.
然后使用ls命令。
open file npy_common.h
and change the line
npy_common打开文件。改变直线。
#if NPY_INTERNAL_BUILD
to #ifndef NPY_INTERNAL_BUILD
如果NPY_INTERNAL_BUILD到#ifndef NPY_INTERNAL_BUILD。
write following command
下面写命令
#define NPY_INTERNAL_BUILD
just after #ifndef NPY_INTERNAL_BUILD
#定义NPY_INTERNAL_BUILD在#ifndef NPY_INTERNAL_BUILD之后。
#2
0
Atul answer helped me, but it was only part of solution. I got fatal error: hdf5.h: No such file or directory
.
阿图尔的回答帮助了我,但这只是解决方案的一部分。我犯了致命错误:hdf5。h:没有这样的文件或目录。
To solve this add:
为了解决这个添加:
find_package(HDF5) include_directories(${HDF5_INCLUDE_DIRS})
find_package(HDF5)include_directories($ { HDF5_INCLUDE_DIRS })
at the end of modules/python/common.cmake file.
在模块/python/common的末尾。cmake文件。