2

I have installed opencv successfully in my system and able to import it without virtualenv. I know I need to copy cv2.so files in my virtualenv directory to be able to use it within virtualenv, but the problem is there is NO cv2.so files in my local site packages. All I can see some .so files named with libopencv-core * alike.

I grep-ed it, tried finding it manually in site-packages, py-modules, but no clue why its isn't there?

I've successfully build and make all files, I am sure there is nothing missed while installing it, because without virtualenv I am easily executing it.

OpenCV Version: 2.4.8 Python Version: 2.7.8 OS: Ubuntu 14.01

Osama Rasheed
  • 159
  • 3
  • 16

1 Answers1

0

To import opencv using your virtualenv you should install it on your virtualenv or copy the cv2.pyd (on windows) to your venv site-packages directory.

If you are on linux you could install it using sudo apt-get install python-opencv.

If you are building it from source you should follow the steps listed here. On step 12:

Also make sure that in the PYTHON field, everything is filled. (Ignore PYTHON_DEBUG_LIBRARY).

Look at the image presented in this step. The python paths listed there should be your venv python paths not your system's python paths.

Hope it helps!

Lucas Infante
  • 798
  • 6
  • 21
  • I'm on linux. Already installed opencv and able to run without virtualenv. Tell me more about fixing PYTHON PATH on linux. – Osama Rasheed Dec 12 '14 at 11:31
  • I don't know how to help adjusting python paths in your case (opencv built from source). It seems to me that in your situation you should reinstall every dependency on your venv, rebuilt opencv and in some step during this process point to your venv python path. Have you tried [this](http://stackoverflow.com/questions/9592389/is-it-possible-to-run-opencv-python-binding-from-a-virtualenv) question/answer and [this](https://medium.com/@manuganji/installation-of-opencv-numpy-scipy-inside-a-virtualenv-bf4d82220313) guide? – Lucas Infante Dec 12 '14 at 11:55