Installing OpenCV with python Latest 2018 Step By Step


I just Finished Setting up OpenCV To work nicely with my python and c++ installations(Ohh god it was a tedious task) although I will be focusing on python only in this post.It took me around 3 hours to figure out how to set it up.Though I searched the whole StackOverflow, google but still no result.There were multiple results on google with different methods but none of them worked for me which in turn prompted me to write this post as I did insane combinations of solution from the internet.So here are my 2 cents -Installing OpenCV with python Latest 2018.

packages used

1.Python 3.6.2 included in Anaconda

Here We have to setup environment variables.For that, you can check these Out Official docs, the video which i followed.

2.OpenCV 3.4.0

So here it is step by step OpenCV For python

1.Install Anaconda, as usual, i.e. next next next and done.

It will install python as well.

2.Download OpenCV from here(well I used 3.4.0 as it was latest at the time of writing)

3.install OpenCV at the desired location.

4.Now more complex part starts

5.Find cv2.pyd in  wherever you have your OpenCV installation in my case it is  C:\opencv\build\python\2.7\x86

6. Paste it into your C:\Program Files\Python36\Lib\site-packages location or wherever you have installed python. CMD or Python IDLE and type “py” or “python” to get into python


8.then type “import cv2″ and enter(if it gives error at this step then continue below at least I got error at this step)

9.Close cmd and reopen again in admin mode then type”py” or “python” then type “pip install numpy”

10. Then Type “pip install matplotlib” do this also in admin mode else it will fail.

11.then type”pip install opencv”

12.Then try  doing 8 step again

13.If you still get an error then try this if you installed python using anaconda.

Open folder where anaconda is installed and then paste the same cv2.pyd file mentioned in step 5 in  Anaconda3\Lib\site-packages 

14.Ten try again step 8 again if it fails again then do this copy python3.dll in your python installations directory     To anaconda.If it exists then rename the one in anaconda directory to python3.txt and then paste it there look at the below image.

15.If after doing all this try again step 8 i.e. open cmd then type”py” or “python” then type “import cv2” and then pray to god and then press enter.It should look something like this

This is the last step I did and then my OpenCV started working.If you are still stuck then god bless you.Ask community over StackOverflow there are really nice people out there.At least I didn’t found anything over StackOverflow at the time of writing this post.

Happy Coding.

1 Comment
  1. raj says


Leave A Reply

Your email address will not be published.