Are you feeling a bit overwhelmed trying to install OpenCV on your system?
If so, don’t worry!
I keep the following page up to date with my latest OpenCV install instructions, ensuring you’re able to successfully install OpenCV on your Linux, macOS, or Raspian (i.e., Raspberry Pi) system.
- Install OpenCV 4 with pip
- Install OpenCV 4 on Ubuntu
- Install OpenCV 4 on macOS
- Install OpenCV 4 on Raspbian/Raspberry Pi
Note: I do not support Windows on the PyImageSearch blog. If you are interested in learning Computer Vision, Deep Learning, and OpenCV, I strongly recommend that you use a Unix-based machine such as Linux, macOS, or Raspbian. If you choose to used Windows, that’s perfectly fine, just understand that I may be unable to help you.
Install OpenCV 4 with pip
Installing OpenCV using pip, Python’s package manager, is by far the fastest and easiest method to install OpenCV on your system.
However, while installing OpenCV via pip is the easiest method, you may want to compile OpenCV from source to obtain access to additional packages/modules as well as optimize the install for your particular architecture.
The rest of the tutorials on this page will help you compile OpenCV from source if you so desire.
Install OpenCV 4 on Ubuntu
When installing OpenCV 4 on Ubuntu, you have two options:
The first is to follow my “pip install opencv” tutorial.
The second option is to compile OpenCV 4 from source using my How to install OpenCV 4 on Ubuntu guide.
Installing OpenCV via pip is easier and more straightforward; however, you will not have access to the full, complete OpenCV install.
On the other hand, compiling OpenCV by hand takes longer, but ensures you have the full install and that the compile is optimized to your operating system and architecture.
Install OpenCV 4 on macOS
If you would like to install OpenCV 4 on macOS, you have two options.
The first option is to simply follow my “pip install opencv” guide.
The second option is to compile OpenCV from source by following by Install OpenCV 4 on macOS tutorial.
Compiling OpenCV 4 on macOS can be challenging if you are new to Unix-based environments, debugging file paths, and using the terminal.
If you have experience with compiling software/packages by hand, then you likely won’t have a problem; however, if you are new to Unix, file paths, or the terminal, I recommend you follow the pip install guide instead.
Install OpenCV 4 on Raspbian (Raspberry Pi)
Compiling and installing OpenCV 4 from source on a Raspberry Pi can be a tedious, time consuming process due to the fact that the Raspberry Pi is so much slower than our laptop/desktop counterparts.
That said, one of the benefits of compiling from source is that you can optimize the install and make OpenCV run significantly faster on the Raspberry Pi compared to the pip-based install.
If you simply want to get up and running with OpenCV on your Raspberry Pi, I recommend following my “pip install opencv” guide.
Otherwise, you can learn how to compile OpenCV from source and optimize the install by following these two guides: