0

I used the following to install opencv

sudo apt-get install libopencv-dev python-opencv

I can "import cv2" fine, read images, manipulate them to my hearts content...everything works great! However, my usr/local/lib/python2.7/site-packages folder is empty!! How can that be?

I'm trying to use virtualenv but according to this I need to install numpy and opencv globally (which I have done successfully) and then copy cv* from the global site-packages dir to the virtual environment site-packages dir. But, my global site-packages dir is empty!

I do see some cv* stuff on my pi:

usr/lib/pyshared/python2.7/cv2.so
usr/lib/pymodules/python2.7/cv2.so
usr/lib/pymodules/python2.7/cv.pyc
usr/lib/pymodules/python2.7/cv.py

I copied the items from usr/lib/pymodules/python2.7/cv* to my virtualenv site-packages dir but still no love...

>>> import cv2
ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: numpy.core.multiarray failed to import

1 Answer 1

1

I got this to work and I will spell out what I did but not sure exactly WHY it worked so feel free to educate me with another answer or comments.

After copying the cv* to my virtualenv dir I ran this (even though I had run it just prior to sudo pip install virtualenv)...

sudo apt-get update
sudo apt-get install python-dev

I then activated my virtualenv and ran this...

pip install numpy

which took a LONG time to do its thing! Without the apt-gets above this would fail very quickly because of not finding some .h files. But now I can import cv2 and numpy into my virtualenv!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.