Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ImportError:ubuntu 16.04 Anaconda2中没有名为cv2的模块_Python_Opencv_Ubuntu_Anaconda - Fatal编程技术网

Python ImportError:ubuntu 16.04 Anaconda2中没有名为cv2的模块

Python ImportError:ubuntu 16.04 Anaconda2中没有名为cv2的模块,python,opencv,ubuntu,anaconda,Python,Opencv,Ubuntu,Anaconda,我知道这是一个常见的问题,但我先尝试了所有的方法 下面显示了问题以及我尝试过的内容: $ python Python 2.7.13 |Anaconda 4.3.0 (64-bit)| (default, Dec 20 2016, 23:09:15) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. Anac

我知道这是一个常见的问题,但我先尝试了所有的方法

下面显示了问题以及我尝试过的内容:

$ python
Python 2.7.13 |Anaconda 4.3.0 (64-bit)| (default, Dec 20 2016, 23:09:15) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import caffe
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv2
>>> import numpy
>>> print numpy.__version__
1.11.3
>>> 
生成pycaffe的错误消息

$ make pycaffe
LD -o .build_release/lib/libcaffe.so.1.0.0-rc5
/usr/bin/ld: cannot find -ltbb
collect2: error: ld returned 1 exit status
Makefile:574: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc5' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0-rc5] Error 1
cocadas@cocadas-ThinkPad-W540:~/Program/caffe-master$ 
由于缺少ltbb,我安装了这个包

$sudo apt-get install libtbb-dev
然后“找不到-ltbb”的问题就消失了。但随后,它就开始抱怨了

.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
.build\u release/lib/libcaffe.so:对'cv::imread(cv::String const&,int)'的未定义引用
.build_release/lib/libcaffe.so:cv::imencode(cv::String const&,cv:_inputarrayconst&,std::vector&,std::vector const&)的未定义引用
.build_release/lib/libcaffe.so:对“cv::imdecode(cv::_inputarrayconst&,int)”的未定义引用

在使用opencv 2.4.11构建caffe 1.0.0-rc5时,我遇到了一个错误:

[ 81%] Linking CXX executable compute_image_mean
../lib/libcaffe.so.1.0.0-rc5: undefined reference to `cv::imencode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<unsigned char, std::
allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
../lib/libcaffe.so.1.0.0-rc5: undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
collect2: error: ld returned 1 exit status
tools/CMakeFiles/compute_image_mean.dir/build.make:130: recipe for target 'tools/compute_image_mean' failed
make[2]: *** [tools/compute_image_mean] Error 1
CMakeFiles/Makefile2:625: recipe for target 'tools/CMakeFiles/compute_image_mean.dir/all' failed
make[1]: *** [tools/CMakeFiles/compute_image_mean.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 81%] Linking CXX executable convert_imageset
然后建造工作进行得很顺利

(root) root@625fbd309a17:~/caffe-rc5/build# PYTHONPATH=~/caffe-rc5/build/install/python/ python -c 'import caffe; print caffe.__version__'
1.0.0-rc5

我不确定,但可能缺少的函数存在于opencv_imgecodecs.so中,它在2.4.11中没有提供,但在>=3.0.0中提供了,对于Importingdg cv2,我使用了

pip安装opencvpython


试试看,也许它能用。

你是如何安装OpenCV的?我按照这个步骤确认OpenCV的安装。Cmon Quora不是获取软件安装问题答案的合适地方,请尝试:谢谢。让我试试看。@ZdaR既然这个问题就在这里,我想OP知道,没必要这么粗鲁。
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
[ 81%] Linking CXX executable compute_image_mean
../lib/libcaffe.so.1.0.0-rc5: undefined reference to `cv::imencode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<unsigned char, std::
allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
../lib/libcaffe.so.1.0.0-rc5: undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
collect2: error: ld returned 1 exit status
tools/CMakeFiles/compute_image_mean.dir/build.make:130: recipe for target 'tools/compute_image_mean' failed
make[2]: *** [tools/compute_image_mean] Error 1
CMakeFiles/Makefile2:625: recipe for target 'tools/CMakeFiles/compute_image_mean.dir/all' failed
make[1]: *** [tools/CMakeFiles/compute_image_mean.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 81%] Linking CXX executable convert_imageset
conda install -c menpo opencv=3
(root) root@625fbd309a17:~/caffe-rc5/build# PYTHONPATH=~/caffe-rc5/build/install/python/ python -c 'import caffe; print caffe.__version__'
1.0.0-rc5