I'm trying to write my own python layer in caffe, and when I try to compile it, I keep getting this import error.
Traceback (most recent call last):
File "/home/username/caffe/layer_example.py", line 3, in <module>
import cv2
ImportError: /home/username/anaconda2/lib/python2.7/site-packages/cv2.so:undefined symbol: _ZN2cv11arrowedLineERNS_3MatENS_6Point_IiEES3_RKNS_7Scalar_IdEEiiid
I've tried to find a solution online, and changed my ~/.bashrc to look like this:
export PYTHONPATH=/home/username/caffe/python:/home/username/anaconda2/lib:$PYTHONPATH
I'm still getting the import error though. Any ideas on what the possible solution might be?
EDIT: Fixed the issue! I uninstalled opencv(2.4.10) on conda, and installed version 2.4.9:
conda install opencv=2.4.9
conda install numpy
That fixed the error for me.
EDIT: Fixed the issue! I uninstalled opencv(2.4.10) on conda, and installed version 2.4.9:
conda install opencv=2.4.9
conda install numpy
That fixed the error for me.
sudo apt-get install python-opencv
could also be a solution. Cuz caffe ubuntu installation guide install says you have to install
libopencv-dev
However, I observed that this package makes opencv only accessible to c++. To use opencv with python I had to install python-opencv
I got this answer from Installing OpenCV for Python on Ubuntu, getting ImportError: No module named cv2.cv
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.