[Image processing] installs the OPENCV on the Mac for Python

Source: Internet
Author: User


Environment: Mac OS X Yosemite v10.10

Tools: MacPorts (download address), MacPorts is similar to the apt-get used in Ubuntu, it can easily install the application quickly, and can make the necessary compiling


Here are the steps:

1, download a macports according to the above download link, now is v2.3.3. and installation is completed;

2,command + space, find terminal and enter, the following instructions are entered in the terminal

3,> sudo port selfupdate

> sudo port install py27-numpy # Py27-numpy is a dependent library of OPENCV, mainly for its array

# When installing NumPy packages and other dependencies, the python2.7.9 will also be installed (if you have not previously installed)

# This process lasts about 30min, and our home is 100M fiber.

> sudo port install opencv +python27 # installs the OPENCV package and compiles it. After the installation is successful, you can use the import cv2 directly in Python

# There are a lot of dependencies to be installed, the brain is up and about to install 30~60min


The above installation smooth fortunately, if the network is very likely to cause some dependent package installation failed, encounter this situation do not fear, more than a few times, or a good environment for the network to continue to install

If a partial installation fails, you will see terminal prompts for errors characters


After installation, perform some necessary tests

1, test Python, enter terminal

> which Python

>/opt/local/bin/python # This result is correct, the wrong result please refer to the following considerations

> Python

>>> Import NumPy # If NumPy installation fails, there will be an error

>>> Import Cv2 # If OPENCV installation fails, there will be an error

>>> exit () # quit Python


Attention:

1, for the output of which Python, if the output is/library/frameworks/python.framework/versions/2.7/bin, it means that the Mac system comes with Python, And this python is not used in the OpenCV library,

Solution: Open terminal, enter > Export PATH = "/opt/local/bin:/opt/local/sbin: $PATH"

So, when we enter the Python directive, we prefer python under the two paths we added above, and this python is macports download and can refer to all MacPorts under the development package.


Welcome friends who have trouble to come to exchange




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.