文章目錄
- 系統環境
- 安裝命令
- 路徑配置
- 解決方法
- 檢驗
系統環境
- MacOS 11.4
- MacBook Pro M1
- homebrew
- python3.9
安裝命令
brew install opencv@3
注意:截至2021年8月,使用國內源安裝會出現404錯誤,
解決方法:不使用國內源
export HOMEBREW_BOTTLE_DOMAIN=''
具體原因參考:修復homebrew安裝軟體404問題
路徑配置
安裝后會輸出如下內容:
==> opencv@3
opencv@3 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.
If you need to have opencv@3 first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/opencv@3/bin:$PATH"' >> ~/.zshrc
For compilers to find opencv@3 you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/opencv@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/opencv@3/include"
For pkg-config to find opencv@3 you may need to set:
export PKG_CONFIG_PATH="/opt/homebrew/opt/opencv@3/lib/pkgconfig"
當我按照要求配置路徑后,python中還是找不到cv2,
解決方法


檢驗
python3
>>> import cv2
>>>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/294390.html
標籤:AI
