Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Building OpenCV 3.2.0 from source on macOS Sierra with Python 3 support

Building OpenCV 3.2.0 from source with Python 3 support

Install OpenCV on macOS Sierra enabling Python 3 with the following instructions:

  • Install CMake, Python 3 + Numpy in advance
  • Download latest OpenCV source code (
  • Move the folder opencv-3.2.0 to the current directory
  • In the current directory, execute the following steps:
mkdir build
cd build
cmake -DPYTHON_DEFAULT_EXECUTABLE=python3 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_opencv_python2=False -DBUILD_opencv_python3=True -DPYTHON3_EXECUTABLE=python3 ../opencv-3.2.0
make -j2
sudo make install
echo /usr/local/lib/python3.6/site-packages >> /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/opencv3.pth
  • Verify installation
python3 -c "import cv2; print(cv2.__version__)"

For python2 support


This comment has been minimized.

Copy link

javadba commented May 24, 2019

made following tweak for g++-9.1: add -DCMAKE_CXX_COMPILER=/usr/local/gcc-9.1/bin/g++-9.1

cmake -DPYTHON_DEFAULT_EXECUTABLE=python3 -DCMAKE_CXX_COMPILER=/usr/local/gcc-9.1/bin/g++-9.1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_opencv_python2=False -DBUILD_opencv_python3=True -DPYTHON3_EXECUTABLE=python3 ../

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.