1. 程式人生 > >Python安裝cv2庫出錯及解決:Could not find a version that satisfies the requirement cv2

Python安裝cv2庫出錯及解決:Could not find a version that satisfies the requirement cv2

原來的安裝命令是:

今天怎麼不靈了?初步判斷是原來使用3.5,現在改用了2.7(專案需要)。

嘗試執行命令:

pip install cv2
Collecting cv2
  Could not find a version that satisfies the requirement cv2 (from versions: )
No matching distribution found for cv2

看到這個錯誤,趕緊搜尋,找到的辦法都無法解決。於是懷疑查詢的更新庫有問題……可是為什麼改了也不對?

後來同事過來一看,直接搜尋cv2,原來安裝辦法是:

sudo apt-get install python-opencv

# 同理,還有其他的:python-scipy/python-numpy/python-matplotlib/python-requests/python-skimage

然後進python, import cv2,成功。

檢視版本號:

python -V
pip -V

filterpy可以直接用pip安裝。
 

sudo pip2 install opencv-python

sudo pip2 install --upgrade pip

sudo pip  install --upgrade pip