Two weeks ago we kicked off the OpenCV 3.0 install-fest with a tutorial on how to install OpenCV 3.0 and Python 2.7 on OSX.
Today I’m back again with another OSX tutorial — only this time we are going to compile OpenCV 3.0 with Python 3.4+ bindings!
That’s right! With the OpenCV 3.0 gold release, we officially have Python 3 support. It’s been a long time coming — and after being stuck in Python 2.7 land for many years, it’s a great feeling to fire up that Python 3 shell and be part of the future of the Python programming language.
In the rest of this article, I’ll show you how to compile and install OpenCV 3.0 with Python 3.4+ bindings.
UPDATE: The tutorial you are reading now covers how to install OpenCV 3.0 with Python 3.4+ bindings on OSX Yosemite and below. This tutorial still works perfectly if you are using OSX Yosemite or prior, but if you want to install OpenCV on the newer El Capitan and macOS Sierra please use this freshly updated tutorial.
How to Install OpenCV 3.0 and Python 3.4+ on OSX
As I mentioned at the top of this article, I have already covered how to install OpenCV 3.0 with Python 2.7 bindings on OSX in a previous post. As you’ll notice, most of the steps are very similar (and in some cases, identical), so I’ve trimmed down the explanations of each step to reduce redundancy. If you’re looking for more details on each step and command, please see the previous post where I go into a bit more detail.
With that said, let’s go ahead and get started installing OpenCV 3.0 with Python 3.4 bindings on OSX.
Step 1: Install Xcode
Before you can compile OpenCV on your system, you’ll first need to install Xcode, which is a set of developer tools provided by Apple for OSX and iOS development. Installing Xcode is very straightforward and can be accomplished by using the App Store application. Simply search for Xcode, click Get, followed by Install App, and your download will start:
The download itself is quite large (> 2gb), and Apple’s content delivery servers aren’t the fastest in the world, so you’ll probably want to go for a walk and get some fresh air while Xcode installs.
Step 2: Setup Homebrew
Homebrew is a package manager for OSX, similar to Ubuntu’s apt-get. We’ll be using Homebrew to help us install and manage some of OpenCV’s prerequisites and dependencies. To install Homebrew, just fire up a terminal and copy and paste the following commands:
$ cd ~ $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" $ brew update
Step 3: Install Python 3
OSX doesn’t ship with a copy of Python 3, so we need to install it via Homebrew:
$ brew install python3 $ brew linkapps
We also need to update our PATH
in ~/.bash_profile
(if the file does not exist, create it) to indicate that Homebrew packages should be used before any system packages:
# Homebrew export PATH=/usr/local/bin:$PATH
Let’s reload our ~/.bash_profile
to ensure the changes have taken affect:
$ source ~/.bash_profile
And lastly, let’s confirm that Python 3.4 has been installed:
$ which python3 /usr/local/bin/python $ python3 --version Python 3.4.3
Step 4: Setup our Python 3.4 environment
Now we can focus on setting up our Python 3.4 environment for the OpenCV compilation.
Using virtualenv and virtualenvwrapper is definitely not a requirement to get OpenCV installed on your OSX machine, but I highly recommend using these packages! Being able to create separate Python environments for each of your projects is incredibly useful, so definitely consider using them!
Anyway, let’s install virtualenv
and virtualenvwrapper
:
$ pip3 install virtualenv virtualenvwrapper
Take note of the pip3
command. I am using pip3
to indicate that the virtualenv
and virtualenvwrapper
packages should be installed for Python 3.4, not Python 2.7 (although these these packages can be used for both Python versions).
We’ll also need to update our ~/.bash_profile
file again by adding the following lines to the bottom of the file:
# Virtualenv/VirtualenvWrapper export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3 source /usr/local/bin/virtualenvwrapper.sh
Followed by reloading our .bash_profile
:
$ source ~/.bash_profile
Now we’re getting somewhere. Let’s create our cv3
virtual environment that OpenCV will use to compile our Python 3.4 bindings against. This virtual environment will also hold any extra packages we want to store for computer vision and image processing development:
$ mkvirtualenv cv3 -p python3
Notice how I am specifying -p python3
to explicitly indicate that we want to create a virtual environment using the Python 3.4 binary.
After the mkvirtualenv
command has executed, we are dropped into our cv3
virtual environment. If you ever want to access this virtual environment again (and as I’ll demonstrate at the bottom of this post), just use the workon
command:
$ workon cv3
And you’ll be placed back into our cv3
virtual environment.
As far as Python prerequisites go, all we need is NumPy:
$ pip install numpy
Notice how I used pip
instead of pip3
here — since we are in the cv3
virtual environment, the virtualenv
and virtualenvwrapper
scripts are smart enough to know that the pip
associated with the cv3
environment should be used so explicitly using pip3
is not necessary.
Step 5: Install OpenCV prerequisites
In order to compile OpenCV from source, we’ll need a few developer tools:
$ brew install cmake pkg-config
Along with a few packages to handle reading various image formats from disk:
$ brew install jpeg libpng libtiff openexr
And another couple packages to optimize various routines inside OpenCV:
$ brew install eigen tbb
Step 6: Compile OpenCV
The first step in compiling OpenCV is to grab the source code from GitHub and checkout the 3.0.0 version:
$ cd ~ $ git clone https://github.com/Itseez/opencv.git $ cd opencv $ git checkout 3.0.0
Update (3 January 2016): You can replace the 3.0.0
version with whatever the current release is (as of right now, it’s 3.1.0
). Be sure to check OpenCV.org for information on the latest release.
We’ll also grab the opencv_contrib package as well which contains extra modules for OpenCV, such as feature detection and local invariant descriptors (SIFT, SURF, etc.), text detection, and more:
$ cd ~ $ git clone https://github.com/Itseez/opencv_contrib $ cd opencv_contrib $ git checkout 3.0.0
Again, make sure that you checkout the same version for opencv_contrib
that you did for opencv
above, otherwise you could run into compilation errors.
Now that the repositories are pulled down, we can create the build
directory:
$ cd ~/opencv $ mkdir build $ cd build
And use CMake to configure the build itself:
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D PYTHON3_PACKAGES_PATH=~/.virtualenvs/cv3/lib/python3.4/site-packages \ -D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4m.dylib \ -D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/include/python3.4m \ -D INSTALL_C_EXAMPLES=ON \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D BUILD_EXAMPLES=ON \ -D BUILD_opencv_python3=ON \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..
Update (3 January 2016): In order to build OpenCV 3.1.0
, you need to set -D INSTALL_C_EXAMPLES=OFF
(rather than ON
) in the cmake
command. There is a bug in the OpenCV v3.1.0 CMake build script that can cause errors if you leave this switch on. Once you set this switch to off, CMake should run without a problem.
I’ve already explained what each of these options are in my previous post on installing OpenCV 3.0 with Python 2.7 bindings on OSX, so please refer to that post if you want a detailed explanation of each of the arguments.
The gist here is that you want to examine the output of CMake to ensure your Python 3 bindings will be compiled against the Python 3.4 interpreter installed via Homebrew and our cv3
virtual environment:
Notice how our Python 3 interpreter, Libraries, numpy version, and packages path have been picked up by CMake.
Another good check to make is that python3
is in the list of modules To be built:
If you do not see python3
in the list of modules to be built and is in the Unavailable list, then you’ll need to go back to the CMake step and ensure the paths to your PYTHON3_PACKAGES_PATH
, PYTHON3_LIBRARY
, and PYTHON3_INCLUDE_DIR
are correct. Again, I have provided a detailed explanation of each of these options in my previous post on installing OpenCV 3.0 on OSX, so please refer there for more information.
Assuming CMake has returned without any errors, we can now compile OpenCV:
$ make -j4
For a faster compilation, replace the 4 with the number of cores available on your system.
The compile time itself should not take more than 5-10 minutes, so grab a cup of coffee while OpenCV installs, and when you get back (assuming that OpenCV compiled without error, of course), you can install it:
$ make install
If for some reason you get an error related to having invalid permissions to install OpenCV, just prepend sudo
to the command:
$ sudo make install
Step 7: Verify the install
At this point, OpenCV 3.0 with Python 3.4+ bindings should be installed on your system. You can verify this by changing directory to where our cv3
virtual environment lives and checking for the cv2.so
file:
$ cd ~/.virtualenvs/cv3/lib/python3.4/site-packages/ $ ls -l cv2.so -rwxr-xr-x 1 admin _developer 2013028 Jun 19 06:11 cv2.so
Sure enough, our OpenCV bindings are sitting in the site-packages
directory for our cv3
virtual environment.
Note: You’ll also be able to find the cv2.so
file (again, which are your OpenCV bindings) in your build/lib
directory as well. The make install
script takes our cv2.so
file and copies it to our target site-packages
directory.
Finally, let’s verify our install by opening up a shell and importing OpenCV:
(cv3)74-80-245-164:~ admin$ python3 Python 3.4.3 (default, Jun 19 2015, 05:23:16) [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> cv2.__version__ '3.0.0'
Congrats, you now have OpenCV 3.0 with Python 3.4+ bindings installed on your OSX system!
What's next? We recommend PyImageSearch University.
84 total classes • 114+ hours of on-demand code walkthrough videos • Last updated: February 2024
★★★★★ 4.84 (128 Ratings) • 16,000+ Students Enrolled
I strongly believe that if you had the right teacher you could master computer vision and deep learning.
Do you think learning computer vision and deep learning has to be time-consuming, overwhelming, and complicated? Or has to involve complex mathematics and equations? Or requires a degree in computer science?
That’s not the case.
All you need to master computer vision and deep learning is for someone to explain things to you in simple, intuitive terms. And that’s exactly what I do. My mission is to change education and how complex Artificial Intelligence topics are taught.
If you're serious about learning computer vision, your next stop should be PyImageSearch University, the most comprehensive computer vision, deep learning, and OpenCV course online today. Here you’ll learn how to successfully and confidently apply computer vision to your work, research, and projects. Join me in computer vision mastery.
Inside PyImageSearch University you'll find:
- ✓ 86 courses on essential computer vision, deep learning, and OpenCV topics
- ✓ 86 Certificates of Completion
- ✓ 115+ hours of on-demand video
- ✓ Brand new courses released regularly, ensuring you can keep up with state-of-the-art techniques
- ✓ Pre-configured Jupyter Notebooks in Google Colab
- ✓ Run all code examples in your web browser — works on Windows, macOS, and Linux (no dev environment configuration required!)
- ✓ Access to centralized code repos for all 540+ tutorials on PyImageSearch
- ✓ Easy one-click downloads for code, datasets, pre-trained models, etc.
- ✓ Access on mobile, laptop, desktop, etc.
Summary
In this tutorial we learned how to compile and intall OpenCV 3.0 with Python 3.4+ bindings by hand using the CMake utility (if you’re looking for a tutorial on installing OpenCV 3.0 with Python 2.7+ bindings, please see my previous post). Granted, compiling by hand is not exactly the most fun experience — but it does give us complete and total control over the install.
Luckily, just a week ago an OpenCV 3.0 install script was created for Homebrew in the science tap. In future posts, I’ll demonstrate how to utilize Homebrew to greatly simplify the compile and install process, making our lives substantially easier.
All that said, I still recommend that you try installing OpenCV 3.0 by hand — Homebrew is nice, but you’ll never get the same full control like when you use CMake.
To be notified when the Homebrew + OpenCV 3.0 install post goes live, please enter your email address in the form below, and I’ll be sure to ping you when the tutorial is published.
Join the PyImageSearch Newsletter and Grab My FREE 17-page Resource Guide PDF
Enter your email address below to join the PyImageSearch Newsletter and download my FREE 17-page Resource Guide PDF on Computer Vision, OpenCV, and Deep Learning.
frank frederic
thank you very much Adrian,
eagerly waiting for instructions for Linux and RaspPi2 (opencv 3 + python 3)
frank
Adrian Rosebrock
Thanks Frederic! They should be online within the next 2-3 weeks.
Vlad
I had to add a few options for cmake to make it work. One is to force making the python3 libraries:
-D BUILD_opencv_python3=ON
And the other to set the numpy library path correctly:
-D PYTHON3_NUMPY_INCLUDE_DIRS=/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numpy/core/include
So my final command was (I also removed the C examples):
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D PYTHON3_PACKAGES_PATH=/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages \
-D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4.dylib \
-D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/include/python3.4m \
-D PYTHON3_NUMPY_INCLUDE_DIRS=/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numpy/core/include \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/Projects/opencv_contrib/modules \
-D BUILD_opencv_python3=ON ..
Adrian Rosebrock
Hey Vlad, thanks for sharing! However, I will say that the cmake command you shared does not utilize virtual environments which is something a really recommend using. In a future post I’ll also show how to compile and install OpenCV 3 on OSX with Homebrew so that will make life even easier!
Nils
+1 for adding `-D BUILD_opencv_python3=ON`, mine did not find Libraries, numpy, or package path until then.
My cmake still read:
Python (for build): /usr/local/bin/python2.7
I installed anyways and verified that opencv3 and python3 work in my virtualenv. Who knows?
Adrian Rosebrock
Thanks for the tip Nils — I’ll go ahead and add the
-D BUILD_opencv_python3=ON
option into the post to ensure CMake always picks it up.As for the
Python (for build)
option, don’t worry about that — it will not update based on which Python version bindings you are compiling. As long asopencv3
is included in the “OpenCV modules” section and your correct version of Python and NumPy have been picked up, that’s all that matters.Hongtao
Hi Adrian,
When I am compile my opencv, I already receive following error.
Scanning dependencies of target opencv_python3
[ 86%] Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o
/Users/hongtaowang/opencv/modules/python/src2/cv2.cpp:6:10: fatal error:
‘Python.h’ file not found
#include
^
[ 86%] Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_detection.dir/tutorial_code/calib3d/real_time_pose_estimation/src/CsvReader.cpp.o
[ 86%] Building CXX object modules/stitching/CMakeFiles/opencv_test_stitching.dir/test/test_blenders.cpp.o
1 error generated.
make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1
make[1]: *** [modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs….
Do you have any clue for that?
Adrian Rosebrock
Hey Hongtao, it looks like the Python development files are not installed on your system. Have you installed Python via
brew install python
?Hongtao
Thanks for your reply. Finally, I found the problem. I do install python through home-brew. The problem is my folder has a different with your tutorial and I didn’t notice that. After correct the folder name, the problem is solved.
Adrian Rosebrock
Awesome, glad to hear it 🙂
Hackeron
Ah, the correct command for my system is:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D PYTHON3_PACKAGES_PATH=/usr/local/lib/python3.4/site-packages \
-D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4m.dylib \
-D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/include/python3.4m \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \
-D BUILD_opencv_python3=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..
Adrian Rosebrock
Thanks for posting the command that worked for you! I’ll be sure to create a FAQ question for this post that helps resolve these issues.
anthony
I met the same error, will you tell me more details about how to fix it? I haven’t found the different folder between mine with the tutorial.
Thx~
Akshay
Hey Adrian,I’m having the same problem.I did install Python using brew install python..
/Users/akshay/opencv/modules/python/src2/cv2.cpp:6:10: fatal error: ‘Python.h’
file not found
#include
I’ve been trying to get a solution for hours now,and it’s really frustrating.Where have I been going wrong?Can you please help?
Adrian Rosebrock
It looks like for whatever reason, CMake is not trying your Python header files. Be sure to check the
PYTHON3_INCLUDE_DIR
switch and ensure that it is pointing to a valid header file. The headers are likely in a sub-directory of/usr/local/Cellar/python3/
like in the CMake command I detailed, but your paths might be slightly different. I would start investigating there.Akshay
Thank you soooooo much Adrian!Really appreciate your help!
Turns out that one of the subdirectories was named 3.4.3_2 instead of 3.4.3.
Thanks again man!It was a really really good tutorial btw.
Adrian Rosebrock
Nice! Congrats on fixing that issue! 🙂
Kyle
Hey, I’m stuck on the same issue…I also had a file named 3.4.3_2 instead of 3.4.3. I corrected this file, but I’m still getting the same error. Did you do anything additional to get the fix? I’ve been banging my head against the wall for hours. Any help is greatly appreciated!!!
sarath
Hey, Kyle Did you figure out the solution for the error? I struck at the same issue.
mcha
1. Thanks Adrain for the tutorial
2. Thanks Hongtao for posting the solution
3. I faced the same issue and here is how I solved it:
I used the command
`python3-config –include` to find my header location
then replaced 3.4 with 3.5 NOTICE, it is in /Library/Frameworks/Py……
my cmake command became like this:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D PYTHON3_PACKAGES_PATH=~/.virtualenvs/cv3/lib/python3.5/site-packages \
-D PYTHON3_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5m.dylib \
-D PYTHON3_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \
-D BUILD_opencv_python3=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..
hope it helps
shmru
Hey, thanks for the help ! Only your cmake worked for me, and I’m stuck at this problem for like hours!!!
Mojo_jojo
Thanks, had the same issue. Your solution fixed it!
Diemesleno Souza Carvalho
Wonderful tutorial Adrian,
Thank you very much.
I have Anaconda with Python 3.4 in my system, but I followed your tutorial and just changed to my python environment and all worked perfect.
\o/
Adrian Rosebrock
Fantastic, glad to hear it 🙂
Josh
Thank you for leaving this comment, I was just wondering if doing this exact thing would work!
Freeman Zhang
As python2.7 is installed by default in OS X (10.10), I think it’s better to add one more cmake option:
-D PYTHON_EXECUTABLE=
(from my experience, it still build python 2.7 module without this option)
I use the following cmake command with options to build opencv 3.0 and install to VIRTUAL_ENV directory.
$ PYTHON3_DIR=`python3-config –prefix` # Get python 3 path
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=$VIRTUAL_ENV \
-D PYTHON_EXECUTABLE=$VIRTUAL_ENV/bin/python3 \
-D PYTHON3_PACKAGES_PATH=$VIRTUAL_ENV/lib/python3.4/site-packages \
-D PYTHON3_INCLUDE_DIR=$VIRTUAL_ENV/include/python3.4m \
-D PYTHON3_LIBRARY=$PYTHON3_DIR/lib/libpython3.4m.dylib \
-D PYTHON_NUMPY_INCLUDE_DIRS=$VIRTUAL_ENV/lib/python3.4/site-packages/numpy/core/include/numpy
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \
-D BUILD_opencv_python3=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..
It can avoid conflicts from opencv 2.0 in Homebrew if install opencv 3.0 to another directory instead of /usr/local.
And add these lines in $VIRTUAL_ENV/bin/postactivate to make sure dynamic libraries of opencv 3.0 can be found:
if [ “x${DYLD_LIBRARY_PATH}” == “x” ]
then
export DYLD_LIBRARY_PATH=$VIRTUAL_ENV/lib
else
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$VIRTUAL_ENV/lib
fi
Adrian Rosebrock
Very nice, thanks for the tip! I had not seen the python27 module built in this way, but it’s clear that many others are having different experiences.
Nirvana
I kept seeing the following, under the Python 3 section:
— numpy: NO (Python3 wrappers can not be generated)
I realized I needed to update “PYTHON_NUMPY_INCLUDE_DIRS” to “PYTHON3_NUMPY_INCLUDE_DIRS”
Adrian Rosebrock
Thanks for the tip!
Max
Following these instructions exactly and cannot get cmake to build using python 3. consistently reverts to python 2.7 despite all previous steps executing flawlessly. :-/
Adrian Rosebrock
Hey Max, it definitely sounds like CMake is wanting to build Python 2.7 support. Take a look at Vlad’s comment above, he mentioned a change to the CMake script that worked for him.
zyyw
That’s fantastic!!!
Roger
Hi Adrian,
thanks for this post. Although I agree that using cmake offers more control and is useful chasing bugs in the brandnew opencv3, for many people starting to play with computer vision the homebrew post will be very attractive as well.
As for me, I can confirm that instead of using homebrew I installed macports and used the command ‘sudo port install opencv +python34’ to get it working (well, I can import cv2, I don’t know about all the rest, yet).
Adrian Rosebrock
Hey Roger, I’ll be doing a new blog post on installing OpenCV 3 and all the extras using Homebrew in a few weeks. In general, I don’t recommend using MacPorts. It’s starting to show it’s age Homebrew provides better support.
Eric
Hi I followed these directions last week and all worked great. However things got pretty broken after upgrading to Python 3.5.
I’ve attempted to start from scratch and follow these directions again, but can’t seem to get past the numpy step. After much churning, the error is “Failed building wheel for numpy”. I know there is a lot more output you’d need in order to truly diagnose this issue, but perhaps you have some insight on something you expect to change with regards to Python 3.5?
Adrian Rosebrock
Hey Eric, I personally haven’t tried upgrading to Python 3.5, mainly because I knew upgrading would break a bunch of things. Basically, any package you installed for Python 3.4 has to be re-compiled and re-installed for Python 3.5. Unfortunately, I do not have any insight into this issue.
Steve
I just followed your tutorial using Python 3.5 and had it working after building from scratch. All I did was replace every 3.4.X with either 3.5.0 or 3.5 depending on where the substitution is taking place.
Adrian Rosebrock
Very nice Steve!
Jeff
I had to rename the cv2.so in site packages from cv2.cpython-35m-darwin.so to cv2.so when compiling with python 3.5.
also, i had to use pip3 to install numpy despite statements to the contrary above. everything seems in working order now! thanks!!
Adrian Rosebrock
The
cv2.cpython-35m-darwin.so
is a really strange bug that I run into myself. I’m honestly not sure why that happens. But as you said, renaming tocv2.so
will fix the issue.Wai Yan
Thank You so much for the step by step tutorial.
Adrian Rosebrock
No problem, I’m happy it worked for you!
ST
Hi Adrian,
A quick question, say if I install openCV 3 on my mac, will I be able to still use my old openCV (which is already installed with Python 2.7)?
ST
Adrian Rosebrock
It depends on how you actually install it. If you already have OpenCV 2.4 installed, then run everything in this tutorial up until the
make install
. From there, all you need to do is keep theopencv/build
directory and sym-link thecv2.so
file into yoursite-packages
directory. This is exactly what I do to run multiple OpenCV versions on my own system.Rick
Adrian, I just got a new iMac running El Capitan, python 3.5 in the office. I followed the instructions without any problem. Thanks a lot. Just one point on the last part of the instructions on checking the location of cv2.so. It is not in ~/.virtualenvs/cv3/lib/python3.5/site-packages/. It is located at /usr/local/lib/python2.7/site-packages/. Other than that, everything is just working smoothly as always.
Adrian Rosebrock
Hey Rick, thanks for the comment. If the
cv2.so
files ended up in the Python 2.7site-packages
directory and Python 3.5site-packages
directory, make sure you double check the output of CMake and ensure you compiled Python 3 bindings (and not Python 2.7 bindings). Other than that, it sounds like you’re good to go!Neeraj
Hi Adrian,
I figured out the problem with the compilation issue which I faced yesterday and also posted my error to you, I just figured it out, I was using wrong python3 version and not from the homebrew directory, I think i installed python3 from somewhere else which broke the whole build process earlier, but now i cleaned homebrew and installed, everything worked for me now..
Thanks for all the help and for publishing such great blogs.Keep up the good work.
Adrian Rosebrock
Congrats on getting everything working Neeraj!
Jim Selikoff
Adrian, thanks so much for these tutorials! I’m also using Python 3.5, but did not rename cv2.cpython-35m-darwin.so and everything worked fine.
-jim
Adrian Rosebrock
I’m glad it worked for you Jim!
Jean Bilheux
This is what I call a good tutorial
Thanks a lot.
By the way I tried to install it with python 3.5 just by curiosity… did not work.
only 3.4+ (as the title says)
Adrian Rosebrock
You can certainly use this tutorial to install with Python 3.5, but you’ll need to change the CMake command, specifically the
PYTHON3_PACKAGES_PATH
,PYTHON3_LIBRARY
, andPYTHON3_INCLUDE_DIR
to point to your 3.5 installation versus the 3.4.RAD
Hi, when I put cmake step I get this error
What can I Do?
Adrian Rosebrock
I assume you are compiling OpenCV 3.1.0 instead of OpenCV 3.0.0? If so, just remove the
-D INSTALL_C_EXAMPLES=ON
from the CMake command and that should fix the issue. There is a bug in the OpenCV 3.1.0 CMake script that is causing this error.RAD
Yes. I’m sorry for this question.
Thank you so much for you work here.
Adrian Rosebrock
No worries, I’m happy I could help out. I have also updated the blog post to mention that the flag should be turned off.
mathivanan
some one send me the ball tracking code using python3 and opencv3.
Adrian Rosebrock
Updating the code to work with Python 3 and OpenCV is pretty trivial:
1. Update
cv2.findContours
:(_, cnts, _) = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
2. And change
xrange
torange
And it will work for both Python 3 + OpenCV 3.
In the future, try to work with the code yourself and ask specific questions for help, rather than posting on an unrelated blog post looking for a “done for you” solution. This is a teaching blog where we all help each other out.
aoy
hello can you help me i’m at step 4
$ pip3 install virtualenv virtualenvwrapper
and it says
-bash: /usr/local/bin/pip3: /usr/local/opt/python3/bin/python3.5: bad interpreter: No such file or directory
what should i do ?
Adrian Rosebrock
It sounds like pip is pointing to the wrong version of Python.
jacob
I had this problem, and reinstalled/updated python which seemed to work.
Mike
Hi Adrian, thanks so much for the installation guides. I’ve installed on a variety of Debian/Ubuntu and Raspbian Jessie using your guides, all Python 3.4 and OpenCV 3.0.0. But I probably had the hardest time with Mac OS X, 10.11.2. Brew now installs python3.5.1, and adjusting the locations in the cmake command got it to work, although I had to make a number of edits to the cmake command, which I’ll include below.
I also had to do `brew install opus free type libass` to eliminate some link errors.
Also, while iteratively working out the configuration, it’s necessary to reset the `build` directory from scratch once in a while, especially when results don’t seem to make sense. I just delete the whole directory and restart.
After a `make install` I was able to `import cv2` right away.
Here is a gist for the `cmake` command that worked for me (note that I put the source under `~/src`, and turned off the examples): https://gist.github.com/mklein9/5a59469d3cd17ffc09c6
-Mike
Adrian Rosebrock
Thanks for sharing Mike!
Philip
Hi Adrian
Thank You so much for an impeccable and extremely useful tutorial. One or too copy-paste glitches didn’t stop me from completing your super set-up! On the OpenCV front, I share your interest in python, search and images with UNMOVIE 2002 which due to security issues is not online ATM, but it will be…
Cheers, Philip
Anura
Hi Adrian,
With the help of your blog and respondents, i was able to compile OpenCV 3.1.0 and Python 3.5.1.
1. I had some problems with Step 4. After combing the net i found the following command and applied it before Step 4
brew link python3 -v
Only then i could proceed.
2. In Step 7 of verify install my .so file is in the form of cv2.cpython-35m-darwin.so. I used your solution in Step 11 of your Ubuntu page ( https://pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/)
Below is the cmake command with the help of you guys here
So far the import cv2 works. Going to try the other projects soon.
Rgds,
Anura
Adrian Rosebrock
Thanks for sharing Anura! Congrats in getting OpenCV installed.
Chen Ruo
Hi Adrian, thank you so much for the tutorial. I managed to install them correctly despite some errors here and there because python is in its 3.5.1 version.
I am a beginner on both python and openCV, and I just bought my new Macbook. I hope you don’t find my question stupid.
I used to code on Sublime Text3 using my Windows laptop and I don’t have problem importing. However, I tried to import cv2 after installing successfully, and run the code using Sublime Text 3, it gave me this error “ImportError: No module named cv2”. I realised when I tried import cv2 under the cv3 virtual environment, it is successful. How do I change to this cv3 virtual environment in the code itself so sublime text 3 can actually find the cv2 module? Do I need to change my path to the usr/local/bin to use the Python3?
Adrian Rosebrock
Congrats on getting OpenCV installed! Sublime Text doesn’t natively support virtual environments, but I believe there is a plugin for that. Otherwise, you should use Sublime Text as your code editor and then execute the code via command line inside the
cv3
virtual environment.0mza987
Hi, thank your detailed article very much. I have successfully installed all of the things. But I have one small question : After the installation can I delete the opencv and opencv_contrib files or I have to keep them as long as I need to use opencv functions?
Adrian Rosebrock
As long as you have executed
sudo make install
, you can safely delete theopnecv
andopencv_contrib
directories.Frank228
Hi, thank you for your detailed tutorial. I have installed opencv 3.1 successfully on my mac. But I have two more questions: I can only import cv2 module when I run python3 under ~/.virtualenvs/cv3/lib/python3.5/site-packages/ this directory in the terminal. How do I import cv 2 module when python3 is ran under ~ directory. And I use Pycharm IDE for coding, why I can’t import cv2 in pycharm IDE. What shall I do?
Adrian Rosebrock
Make sure you are in the
cv3
virtual environment when running Python:As long as you are in the Python virtual environment, the import should work.
As for using PyCharm with the Python virtual environment, be sure to follow this tutorial.
Jorge
Hello, thanks so much for the tutorial, it was easy to follow and worked flawlessly for me! However, after the smooth install of python3, virtualenvs, and openCV3.1.0, I have been running into a few problems, that I think have to do with using virtual environments.
The first one is that I can’t get matplotlib to work in my virtual environment. I can pip install it and even import matplotlib but when I try to import pyplot, python complains of a problem with the backend. Have tried changing the backend (specifically to Qt4Agg, after brew installing sip and PyQt4) and a load of other solutions I found online but to no avail. Do you have any idea what to do?
Secondly, I am having some problems using cv2.VideoCapture() with .avi files. Seems to work fine with .mpg and .mp4 but this one .avi file I have (which is encoded using ffmpeg), gives me ret = False whenever I try to read the video (i.e. ret,im = cv2.VideoCapture(‘file.avi’).read())
If you have any ideas as to how to fix either of these problems, it would be greatly appreciated!!
Adrian Rosebrock
Nice, I’m happy to hear the install went well!
As for your matplotlib issue, this post demonstrates how to resolve it. It is indeed a backend issue and it can be fixed by installing matplotlib from source.
As for the .avi files, that’s almost certainly an video codec issue. Unfortunately, getting certain video codecs to work are a bit of a dark art. You might want to re-compile and re-install OpenCV with FFMPEG support enabled. But again, this will likely take some trial and error.
Massimo Di Stefano
Hi Adrian, I followed your instructions. I’m able to import cv2 in python3 but can’t have sift working. I added a comment on this github issue on the opencv_contrib repository:
https://github.com/Itseez/opencv_contrib/issues/541
I thought it was related. Have you any clue on how to debug this problem or if I’m missing something?
Thanks!!!
Adrian Rosebrock
Outside of this blog post which discusses where SIFT and SURF went in OpenCV 3, I’m not sure what the particular issue may be. When you pulled down
opencv
andopencv_contrib
from GitHub, did you make sure to checkout the same versions of both repositories? I’ve seen this cause problemsi n the past.Wes
Accidentally hit enter. Keyboard struggles.
1. It looks like the C examples flag works as of posting this.
2. The latest XCode toolchain 7.3 seems to have broken the build so I am going to try reverting to XCode 7.2.1 and see if that fixes the issue.
Adrian Rosebrock
Thanks for sharing Wes!
Sam LEE
Hi I have getting trouble to install on my Mac 10.11
@ Step 6: Compile OpenCV
I can not cd opencv
after that everything was not massed.
Could you please help me to continue from Step 6 ??
Where is the opencv directory on my mac ?
Thanks
Sam
Adrian Rosebrock
The
opencv
directory should be in the same directory as where you executed thegit clone https://github.com/Itseez/opencv.git
command.Shreyash Agarwal
Hi Adrian, Python is currently at 3.5.1
Please update your post to include the relevant versions..
I installed it in Applications/ Folder instead of the root home folder.
Installed correctly, also had to do rename the .so file at site-packages as it was named something else…
mv cv2.cpython-35m-darwin.so cv2.so
Then could import it in python3 🙂
Cheers Adrian!
I’m learning from your blog everyday.
Adrian Rosebrock
Thanks for sharing your CMake command Shreyash!
Peter
Hey Adrian, I’ve been having troubles with the cmake command, as underneath the Python 3: section, it can’t find the interpreter or the library. I have python 3.5.1, tried the cmake commands listed above, and double checked with my directories. Do you have any idea what I might have missed? Thanks!
Adrian Rosebrock
This blog post assumes you’re using Python 3.4.3, but no worries! Simply change occurrences of 3.4.x to 3.5.x in your CMake command and it should run without a problem (although you’ll want to double-check that the paths are valid).
JSch
Hey Adrian!
I have found the solution for my previous problem! But now I am not able to use the CV3 in my virtual environment. The thing is even though I copy the cv2.so to ~/Envs/cv3 folder it doesn’t work! The test you showed at the end of the tutorial runs the phyton shell inside the folder where the cv library is, my question is: How can I put the library inside any other environment? Do I have to repeat the tutorial? If yes what do I have to change?
Many thanks again for this incredible tutorial Adrian!
Adrian Rosebrock
If you would like to use your OpenCV bindings in any other virtual environment, you can simply copy or sym-link the file into the
site-packages
directory of each virtual environment. As for importing OpenCV, make sure you have executed theworkon
command before executingpython
.Peter
Hey Adrian, I made some progress but I keep on running into this error while running make -j4
“/Users/peter/opencv_contrib/modules/hdf/include/opencv2/hdf/hdf5.hpp:40:10: fatal error:
‘hdf5.h’ file not found”
Do you have any idea how to solve this? Thank you!
Adrian Rosebrock
For some reason your install of OpenCV wants to compile HDF5 support. I would install it via Homebrew:
$ brew install hdf5
You may need to run
brew tap homebrew/science
before running the above command, but I’m not sure regarding the package structure.Then try to re-install OpenCV.
Vinay
Hi Adrian,
A very nice tutorial. Thank you.
I had this issue and I fixed it by installing hdf5 using the following command.
brew install homebrew/science/hdf5
Adrian Rosebrock
Thanks for sharing Vinay! It looks like CMake was trying to compile OpenCV with HDF5 support. This normally isn’t enabled by default, but in your case, installing HDF5 would indeed resolve the issue.
Fatima
Hello!
I have a couple of questions.
1. After we make the virtual environment at the end of step 4, do we stay in that environment for the remainder of the steps?
2. At the end of step 3, when I ask ‘which python3,’ I get:
/usr/local/bin/python
instead of what you get:
/usr/bin/local/python
Does this mean I did something wrong when installing python?
Thank you very much for your help!
Adrian Rosebrock
Yes, after you create the virtual environment, you should stay in it for the rest of the steps. As for the
/usr/bin/local/python
, that is a typo on my part. I will correct that.Clara
Like many other recent users, I found this tutorial fantastically helpful. However, I also had problems with the -D PYTHON_INCLUDE_DIR command being the wrong link (even though I used brew). I had the same error message as many others:
/Users/hongtaowang/opencv/modules/python/src2/cv2.cpp:6:10: fatal error:
‘Python.h’ file not found
#include
^
For me, I had to change my path to /usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/Headers \
Adrian, could you put a little note (like the one about turning off C examples) in the original post indicating that for later versions people should explore their file structures a bit for the Python.h file, since the path seems to change with different versions of python3? I spent a few hours on the internet googling my error message before I saw all of the responses to this thread.
Adrian Rosebrock
Thanks for the suggestion Clara!
Emma
Hello Adrian,
My python version is 3.5.1
In Step 7, I enter “$ ls -l cv2.so”, it show the error:
ls: cv2.so: No such file or directory
Adrian Rosebrock
If your Python version is 3.5.1, then you’ll need to update your CMake command to point to the correct Python version (3.4 was used in this blog post).
Jack Cai
Hi there
Any chance you can make a tutorial for OpenCV 3 + Python 2.7 or 3.5 on Windows with extra pencv_contrib module. We can easily get OpenCV 3 working with Python 2.7 Visual Studio on Windows but building OpenCV with the extra module seems to be difficult. It would be great if you can help. Thanks.
Adrian Rosebrock
In all honesty, it’s been 9+ years since I’ve used a Windows system. I don’t recommend Windows for computer vision development. And truth be told, I don’t want to support Windows on the PyImageSearch blog. I highly recommend Unix-based systems such as OSX and Linux for CV development.
Roberto
Hey Adrian, thanks for the great tutorial! It doesn’t seem to work on the system I’m using for work though (although it does for my machine at home).
In short, the output of cmake says that the python3 module isn’t available. If I go under the ‘Python 3’ section, it looks like cmake has correctly detected the interpreter, the package path and numpy, but it can’t find the library. I’m pretty sure I’m pointing it to the correct libpython3.5.dylib (I also tried libpython3.5m.dylib – not sure what the difference is) but neither seems to work.
Do you have any ideas?
Adrian Rosebrock
This tutorial was designed for Python 3.4, so if you’re using Python 3.5, the paths will undoubtedly change. I don’t have a Python 3.5 installation on a Mac setup (yet), but as soon as I do, I’ll double-check the paths.
Roberto
You mean change 3.4.3 to 3.5 everywhere? Because that changes, and nothing else. 🙂 pkg-config confirms, and I’m using tab autocomplete to make sure I don’t mistype anything. I don’t think it’s an issue with the paths. I really don’t understand why cmake can’t ‘see’ the library. I wonder if for some reason python 3.5 isn’t supported?
Adrian Rosebrock
Python 3.5 is certainly supported, that’s not an issue at all. The issue is most certainly with the paths, so you might need to tinker with them and ensure that they are changed from 3.4 to 3.5. Exactly what the paths change to is highly dependent on your system.
Raj
Hi Adrian, import cv2 works well with Pycharm though it fails in Terminal, how do I fix it?
Adrian Rosebrock
It sounds like you may not be accessing the
cv3
virtual environment before executing your Python script:Rauf
Hello! Thank you very much for a very helpful tutorial! I’m new in OpenCV and I have a question, maybe you know an answer : how to run the examples in the “text” extra module in C ++?
Hilman
Adrian, I have a question. Successfully installed the OpenCV for Python 3 (in a virtual env of cv3) as your tutorial, is it possible for me to make a Python 2 based virtual env, install dependencies needed by OpenCV, and just symlink the cv2.so file to it?
Thanks in advance.
Adrian Rosebrock
You are correct — you would need to create a Python 2 virtual environment and install NumPy. However, your
cv2.so
file is only compatible with your Python 3 install. You would need to re-compile OpenCV 3 with Python 2 support, then sym-link thecv2.so
file from yourbuild
directory.Steve
Thanks worked like a charm! In Step 7 since you installed virtualenvwrapper you can type (all one word):
cdsitepackages
to change to the virtualenv site-packages directory. Then `ls` should show the cv2.so file.
Adrian Rosebrock
Nice, I didn’t know about the
cdsitepackages
command — thanks for sharing that tip Steve!Mona Jalal
Hi Adrian,
Can you please have a look at this issue? For me cmake, make -j4 and sudo make install works but still can’t import cv2.
Any thought on what is missing or what I should do to fix this would be really helpful.
Thanks,
Mona Jalal
https://github.com/opencv/opencv/issues/7037
Adrian Rosebrock
Hi Mona — unfortunately, OpenCV can be a real pain to install. However, because of this, I can only support the instructions I provide here on the PyImageSearch blog. I hope you understand!
Navin
As a victim of the #include file not found error. Make sure to run python-config –prefix to check youR python3 installation path. At the time of me installing it it was 3.5.2_1 and had to change the cmake command to this and it WORKED, YAY !.
Adrian Rosebrock
Awesome, thanks for sharing Navin! 🙂
Ash
Hey Adrian!
I was able to follow along this tutorial until step 7. At that point when I entered “ls -l cv2.so” I got “ls: cv2.so: No such file or directory” from the terminal. After looking in the “~/.virtualenvs/cv3/lib/python3.4/site-packages/” directory I found that I have cv2.cpython-35m-darwin.so instead of cv2.so. As it stands, I can’t seem to import cv2. I was wondering if there was anything I could do to work around this problem?
Adrian Rosebrock
Hey Ash — it looks like you have your OpenCV bindings compiled correctly. All you need to do is rename
cv2.cpython-35m-darwin.so
tocv2.so
. That will fix the issue.Ricardo
Hey Adrian! nice post, but i was wondering, is there a way to remove/delete all the files created on the process?, in case everything goes wrong?
saludos!
Adrian Rosebrock
During the compile? Simply delete the
build
directory if you would like to restart the process.Gregory Pierce
Note. These instructions will not build OpenCV on OSX 10.12, you will encounter issues with QTKit. You will have to disable videoio by adding this to your cmake “-D BUILD_opencv_videoio=OFF”
Adrian Rosebrock
Thanks for sharing this tidbit Gregory. Does OSX 10.12 come pre-installed with QTKit? Or did you install it on your machine?
Scott
First, thanks for the very detailed instructions. This is very helpful.
Adrian, on Step 6:
$ cd ~
$ git clone https://github.com/Itseez/opencv.git
At this point, are you still within the virtual environment?
In terminal input lines are predicated with (cv3) and I just want to make sure I’m in the right place before continuing.
Adrian Rosebrock
During the
git clone
steps it’s not strictly necessary to be in the virtual environment; however, I would suggest that you do stay in the virtual environment because you’ll soon be running CMake which does assume you are in the Python virtual environment.Scott McAndrew
Appreciate that timely feedback. Thanks Adrian!
Adrian Rosebrock
No worries Scott, happy I could help 🙂
Arthur Gilbert
Hi, Adrian. I’m at the stage compiling openCV (make -j4). Suddenly there is this error when I’m at 28%:
~/opencv/modules/videoio/src/cap_qtkit.mm:46:9: fatal error: ‘QTKit/QTKit.h’ file not found
Do you know what it is and what should I do ?
Adrian Rosebrock
This is a problem with the current release of OpenCV on El Capitan and macOS Sierra systems. There has been a fixed released but it hasn’t been committed to a version number yet. Instead of doing
git checkout 3.0.0
simply just skip that step and work with the development version — this should allow you to avoid the error.Arthur Gilbert
What if I’ve done the git checkout ? Do I need to uninstall everything ?
Adrian Rosebrock
After you’ve done the git checkout simply delete your “build” directory, recreate it, and re-run CMake and make.
Rusu Valentin
Hi,Adrian! i have a problem at the last stage
fatal error: ‘QTKit/QTKit.h’ file not found
#import
Can you help me resolv it? i have tryed everything…i have deleted build directory, added this to my cmake “-D BUILD_opencv_videoio=OFF”,but i still have the same error…I have macOS Sierra 10.12.
What should i do to fix it?
Adrian Rosebrock
I’m in the process of working on a new tutorial to handle installing OpenCV on El Capitan and macOS Sierra. It has become a real pain in the ass for the newer versions of the Mac operating system (hence why I need to create a new tutorial). In the meantime, I would suggest not using Sierra. If you decide to use Sierra you can compile from source by checking out the latest version of opencv and opencv_contrib from their respective GitHubs.
You should also read this comment thread on a separate PyImageSearch blog to help you out.
Rusu Valentin
Thank you for help! i don’t have anymore that error,but now i have fatal error:
‘Python.h’ file not found…
Adrian Rosebrock
It sounds like you don’t have your Python development headers installed or CMake isn’t configured to point to them. Which version of Python are you using? Python 3.4.x? Python 3.5.x? Keep in mind that you’ll need to update your paths in CMake to point to your specific version of Python.
Rusu Valentin
I’m using Python 3.5.2.I don’t realy know how to update paths in CMake…
Adrian Rosebrock
Go back to the CMake command and replace occurrences of Python 3.4 with the correct paths for 3.5 (use tab completion to help you). Otherwise, I would suggest waiting for my updated blog post on installing OpenCV + Python 3.5 bindings on OSX.
Hao
Hi Adrian,
thx for your tutorial as it’s very helpful. I appreciate that you will write a new for Mac Sierra.
To follow this very tutorial, i strongly recommend everyone to use Xcode 7.x combined with macOS Yosemite or El Capitan, as https://developer.apple.com/reference/qtkit .
Thanks again for your work!
Adrian Rosebrock
Hi Hao — the macOS Sierra tutorials will be published on November 28th and December 5th.
Mac Wang
Really looking forward to it. I’ve spent couple nights on this. (opencv3 + python3.5 + MacOS Sierra)
Adrian Rosebrock
I’m not going to lie — they weren’t easy tutorials to put together. They are well worth it though 🙂
Jeepz
I’m attempting to install OpenCV 3.1.0 with Python 3.5.2
I get these two errors.
which python 3
/usr/local/bin/python3
^ should the 3 after python not be there ?
Also, I’ve having trouble installing numpy. Does this version of Python come with pip ? I’ve looked around but can’t seem to be able to install it with the get-pip.py
Adrian Rosebrock
If you are executing the command:
$ which python3
Then yes, the “3” should be there. Once you create your virtual environment using
mkvirtualenv
you can leave off the “3”.As for installing NumPy, create your virtual environment and then run the command:
$ pip install numpy
Willis
When using the cmake, i’ve tried three times. There always be on error called fatal error ‘QTKit/QTKit.h’ not find. I have no idea what happen. so could you please help me figure it out?
Adrian Rosebrock
It sounds like you’re using macOS instead of the older OSX. Please see this blog post to the solution to the QTKit problem.
Dong Gyu Lee
Thank you
Successfully!!!
Installed python 3.6.0 and opencv 3.2.0 in OS Sierra 10.12.3, iMac
Dong Gyu Lee
Adrian Rosebrock
Congrats on getting OpenCV installed!
Max
Hey Adrian,
I have followed your instructions, but the cmake doesnt work. Python2 und Python 3 are not in the “To built” list.. Further upwards in the output of cmake I find the following line:
Could NOT find PythonLibs: Found unsuitable version “2.7.10”, but required is exact version “2.7.13” (found /usr/lib/libpython2.7.dylib)
I downloaded and installed python 2.7.13, but it didnt fix the problem. All my paths are correct, I checked it by cd’ing into the directories.
Thank you very much for your help!
Max
Adrian Rosebrock
Hi Max — I’m sorry to hear about the issues getting CMake configured properly. Have you tried this updated post on installing OpenCV 3 on macOS?
Adrian Rosebrock
Hi Christian — resolving QTKit errors has been addressed in this blog post.
azrnaj
Hi! I am very new at this but your blog posts have kept me moving.Thank you.
Currently working on object detection on tensorflow, now doing real-time object detection using OpenCV. I installed opencv initially via pip and thought that was the only process. Aha!
Anyway, hm dont you do tutorial on OpenCV installation with python 3 for Windows 7? :/
Adrian Rosebrock
Sorry, I do not provide support for Windows on the PyImageSearch blog. See my FAQ for more information.