Opencv and Python/Virtualenv

OpenCV and python/virtualenv?

Virtualenv creates a separate python environment. You will need to re-install all of your dependencies. EDIT it's true pip does not seem to play well with opencv. The missing module error can be resolved by copying cv shared object to your virtualenv. More info in the question linked below.

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

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

Python 2.7 installing opencv via pip (virtual environment)

Python 2.7 is not supported anymore in opencv-python-4.3.0.38. Support was dropped in 4.3.0.36; see this issue.

The workaround I found was to install opencv-python version 4.2.0.32 (which is the latest supported for Python 2.7, see this for all releases) like this:

pip2 install opencv-python==4.2.0.32


Related Topics



Leave a reply



Submit