首页 > 代码库 > 安装opencv在MacOS上
安装opencv在MacOS上
1. 使用brew安装opencv
brew tap homebrew/science
brew install opencv
ls /Users/mac/Library/Python/2.7/lib/python/site-packages
mkdir -p /Users/mac/Library/Python/2.7/lib/python/site-packages
sudo mkdir -p /Users/mac/Library/Python/2.7/lib/python/site-packages
echo ‘import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")‘ >> /Users/mac/Library/Python/2.7/lib/python/site-packages/homebrew.pth
2. 查找到安装opencv库文件位置:
/usr/local/Cellar/opencv/2.4.13.2/lib/python2.7/site-packages/cv.py
/usr/local/Cellar/opencv/2.4.13.2/lib/python2.7/site-packages/cv2.so
3. 加入环境变量:
export PYTHONPATH=/usr/local/Cellar/opencv/2.4.13.2/lib/python2.7/site-packages/:$PYTHONPATH
4. 如果import cv2是出现ImportError: numpy.core.multiarray failed to import 请更新numpy库。
sudo pip install numpy --upgrade --ignore-installed
安装opencv在MacOS上