1. Confirm that Python is installed
python
2. You can directly use brew to install OpenCV under Mac. The specific steps are as follows
add opencv
brew tap homebrew/science
install opencv
brew install opencv
It takes a long time here
3. Install the necessary python libraries
pip install numpy
pip install matplotlib
4. Configure environment variables
vi .bash_profile
添加
export PYTHONPATH=/usr/local/lib/python2.7/site-packages
5. Test whether the installation is successful and enter the python command line
python
import cv2