I need to use opencv in a project that is in a virtual environment, but you cannot install opencv with pip.
installing on my local machine (OSX Yosemite, version 10.10.1) with homebrew works just fine, but I cannot do "brew install" in my virtualenv.
How can I include opencv in my environment?
As long as your virtual environment is active, python and pip link to the same executable files that python3 and pip3 do. Congratulations, you can now install your packages to your virtual environment.
OpenCV can be installed using pip.
As described here (see Option B) you can run this from inside your virtual environment:
pip install opencv-contrib-python
As mentioned at that link, opencv-contrib-python
is an unofficial pre-built OpenCV package.
I tested this on Linux.
I use Windows 10. In my case, in order to use openCV in my new virtual environment, I manually copied all of the files regarding openCV which are in C:\Program Files (x86)\python36\Lib\site-packages to virtual environment directory C:\Program Files (x86)\ibrahim\Lib\site-packages. Then, import cv2 to python and it worked for me. Be noted that you need to copy all of the files inside red boxes that I showed below.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With