That should successfully re-link the python libraries.
Run the command brew unlink opencv3 & brew link -force opencv3. If that doesn't work, go to the next step. Don't worry, it happens to the best of us! Simply brew reinstall opencv3 -with-python3 -c++11 -with-contrib to reinstall with Python 3 support.
You forgot to install using the -with-python3 option.This error can occur for one of three reasons: The contrib module of OpenCV contains some experimental features, including a number of useful feature descriptors like SIFT, SURF, and FREAK.Īfter opening Python and importing OpenCV, you may run into an ImportError: No module named 'cv2'. with-contrib - This is optional, but recommended. By now you're hopefully using a compiler that supports modern C++!
c++11 - Tells Homebrew to build with C++11 support. with-python3 - Tells Homebrew to include Python 3 support for OpenCV. The opencv formula will install the latest version of OpenCV 2. Note that Homebrew has both an opencv and opencv3 package. Let’s break down the commands and options a little bit:īrew install opencv3 - This specifies the package to install. If something went wrong, check out the Troubleshooting section below. If you are using Python 3.4.3, replace python3.5 above with python3.4) Then run this command:Įcho /usr/local/opt/opencv3/lib/python3.5/site-packages > venv/lib/python3.5/site-packages/opencv3.pthĪnd you should now be able to import cv2 from within your virtual environment! If you have a different Python version than 3.5, you will need to change the major version numbers in the command above. Here I assume that the virtual environment exists in the venv directory. Open a command prompt and cd to the directory where your virtualenv is installed. If you're using a virtual environment, there is one more step to get Python to recognize the OpenCV package. The central issue was that OpenCV would not build properly when building against ffmpeg (it will try to do this if ffmpeg is also installed.) As suggested here, the problem can be resolved by using the following brew command to build OpenCV, which forces an alternative version of the build environment (one of the top troubleshooting suggestions. So far I've assumed you're working with the standard Python installation. Type "help", "copyright", "credits" or "license" for more information. First install the opencv3 package with Homebrew, and then tell Python 3 where to look for the OpenCV binary: There are two steps to correctly install Python support. I’ll assume that Homebrew is up-to-date and brew doctor doesn't bring up anything serious before installing OpenCV. What follows are the instructions to correctly install. Even though OpenCV includes the Python 2 bindings by default, the same is not true of Python 3. This seems especially true when trying to use the Python bindings that OpenCV provides. Usually Homebrew makes dependency management a breeze, but OpenCV is a curious exception to this rule. Since our research team all develops on OS X, we also make use of the Homebrew package manager. It’s very useful for implementing computer vision algorithms, but getting the library installed properly isn’t always easy. Introductionĭo you want to use OpenCV, but can't get it to work with Python 3? You've come to the right place! Here at Gravity Jack we tackle computer vision problems using OpenCV as one of the tools in our arsenal. I am so sad about this, and it makes me want to quit programming, since it's just not stable enough due to releases 24/7 breaking older versions.Post by Gravity Jack research team member, Marc Rollins.
Probably one of the worst experiences in my career, you have literally destroyed my internship due to me being on Mac OS X and having so much trouble installing openCV for my internship project, delaying my implementation of Face Recognition because i do not have access to the face submodule in the contrib repository.
You update this library so often that everything else is deprecated before you test it, and i find it so stupid and cannot believe how troublesome it is to install this correctly. It should be as easy as saying: brew install opencv3 -with-contrib -with-python3, but that doesnt even work, nothing really works anymore.
I have searched everything online how to do it and nothing helps. To think that installing openCV and using all of it's features could be so troublesome is beyong my understanding. I must say this is probably the one thing that has caused me the most delays in my career as a programmer. I have tried for days installing openCV with contrib repository without success.