Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run opencv (python binding) from a virtualenv?

I would like to keep everything contained within the virtualenv. Is this possible with OpenCV? I'm fine with building from scratch, do I just need to setup the virtualenv first then use special compile flags to tell it where to install to?

like image 543
xamox Avatar asked Mar 06 '12 21:03

xamox


People also ask

Should I install OpenCV in virtual environment?

We also learned which package to install and how to create a virtual environment for working on the package. For all purposes of learning computer vision using Python, we highly recommend installing opencv-contrib-python using prebuilt binaries.

Which Python version is compatible with OpenCV?

OpenCV 3 works with Python 2.7, 3.4, 3.5, 3.6 and 3.7. The unofficial OpenCV PyPi wheels work for Linux, Mac and Windows.


1 Answers

I found the solution was that I had to copy over cv2.so and cv.py to the directory running the virtualenv, then pip install numpy. To do this on Ubuntu 12.04 I used.

virtualenv virtopencv cd virtopencv cp /usr/local/lib/python2.7/dist-packages/cv* ./lib/python2.7/site-packages/ ./bin/pip install numpy source bin/activate python import cv 
like image 105
xamox Avatar answered Sep 20 '22 08:09

xamox