Wednesday, July 26, 2017

Install OpenCV on Python 3.6 in Virtual Environment

Step1 - Downloaded The Wheel File (whl file)

In this case, my downloaded whl file "opencv_python-3.2.0-cp36-cp36m-win_amd64.whl" is in my folder "Downloads" inside "F" drive

Step 2 - Activate Virtual Environment

If you haven't setup a virtual environment, please follow along the following video
(00:09 sec - 00:17 sec) to install virtualenv
and
(00:18 sec - 01:16 sec) to virtual environment setup

https://www.facebook.com/clueple/videos/1930124850534185/

Go to the virtual environment that you want to use the whl file
In this case, my virtual environment "testGraphics" inside
folder "graphics" in "F" drive.

Go to "F" drive (if you're from default C drive,
simply type "F:"; if you're already in "F" drive,
type "cd \" to get back to the top directory of "F" drive

Activate your virtual environment with the script below:

.\graphics\testGraphics\Scripts\activate.bat

where "graphics" is the folder that holds the virtual environment
and "testGraphics" is the virtual environment folder

Step 3 - Get to the Whl File Location

Once you've activated the virtual environment ("testGraphics"),
go to the file location that your downloaded whl file sits:

In this case, my whl file ("opencv_python-3.2.0-cp36-cp36m-win_amd64.whl")
sits inside folder (F:\Downloads).

Since I am in F drive already, I simply type:
cd Downloads
to get to the "F:\Downloads" folder

Step 4 - Pip Install The whl File And Import Package

Now, you're in F:\Downloads folder.
Type the code below to install the whl file:

pip install "opencv_python-3.2.0-cp36-cp36m-win_amd64.whl"
(hit [enter])

You're ready to use the new Python package

Step 4 (Optional) - To use openCV in Python 3,
you need to import the following:

import cv2
import matplotlib
import numpy

Hope it helps.

Feel free to discuss here:

www.facebook.com/clueple

Pip Install OpenCV in Python 3 virtual environment

P.S. I just shoot a video on how to install OpenCV in Python 3.6 virtual environment (Windows 7)
The steps are more or less the same


No comments:

Post a Comment