I’ve had some minor issues with getting OpenCV to work on my Windows machine and all guides were not helping.
I was following these instructions found on OpenCV official website:
http://docs.opencv.org/3.2.0/d5/de5/tutorial_py_setup_in_windows.html
After installing python, numpy and matplotlib and trying to:
import cv2
I was greeted with the following error:
RuntimeError: module compiled against API version 0xa but this version of numpy is 0x7 windows
After some googling, the reason was quite obvious. I needed to upgrade my numpy version.
Somehow that appeared to be hard to do without Pip. How to get Pip
- Save this as get-pip.py https://bootstrap.pypa.io/get-pip.py
- Open up your cmd
- Type python get-pip.py
- You should be fine now
- To double check it’s indeed installed:
- Go to the location where your python and Scripts folder inside it C:\python27\Scripts
- You should see “pip” named .py file
After installing pip it should be very easy to get numpy installed.
pip install numpy
and to upgrade it to the latest version:
pip install numpy --upgrade
After which when I open my Python IDLE and write
import cv2 print cv2.__version__
I get no errors like the original tutorial said.