Mac OS Installation OpenCV (PYTHON3)

Source: Internet
Author: User
Tags virtual environment virtualenv

My blog address: poke here

To run the command:

brew install opencv3 --with-python3 --c++11 --with-contrib  brew link --force opencv3  

Test:

$ python3  3.5.120201612:52:19)  4.2.17.3.0 (clang-703.0.31)] on darwin  "help""copyright""credits"or"license"for more information.  >>>import cv2  

If there is no error, the installation was successful, congratulations! Explain the above command first.
Brew Install OPENCV3 This command is used to indicate the installation of the Python3 version, (with OpenCV, opencv3 two python versions, the former corresponds to Python2),
--with-python3 used to tell homebrew to let OpenCV support Python3,

--c++11 used to tell homebrew to provide c++11 support,
--with-contrib is used to install OPENCV contrib support.

If after the above steps are still not installed successfully opencv (in fact OpenCV has been installed, but not the correct and python3 associated), you can try again the following command:

brew&&brew link --force opencv3  

Try again whether success, if successful, congratulations you do not have to look down, if not successful, and then look, we are the next task is to properly make Python3 and OPENCV related together. Notice that we have installed the program above using homebrew, homebrew installed program location is below.

So what we need to find is the OpenCV cv2*.so file, (refer to my previous Ubuntu installation OpenCV and finally the associated cv2.so file), and finally my so file location is:

/usr/local/Cellar/opencv3/3.1.0_4/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so  

The following is associated with the PYTHON3 environment, and also with the virtual virtualenv development environment.
I'm associated with a virtual environment, and the Python entity environment is the same, just go to Python3 's Site-packages folder and create a soft link underneath the original so.

cd /usr/local/lib/python3.5/site-packages  ln -s /usr/local/Cellar/opencv3/3.1.0_4/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so cv2.so  

Activating the VIRTUALENV virtual environment, entering Python

>>>import cv2  >>> cv2.__version__  '3.1.0'  

Run the following command to indicate that the installation was successful.

Reference: Poke here

Mac OS Installation OpenCV (PYTHON3)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.