pip install opencv-python
複製代碼
安裝了opencv-python 以後,在使用 import cv2 報錯以下python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/anaconda3/lib/python3.6/site-packages/cv2/__init__.py", line 3, in <module>
from .cv2 import *
ImportError: libSM.so.6: cannot open shared object file: No such file or directory
>>>
複製代碼
報錯緣由: 缺乏共享庫linux
Centos解決方案ide
yum whatprovides libSM.so.6
yum install libSM-1.2.2-2.el7.x86_64 --setopt=protected_multilib=false
複製代碼
Ubuntu解決方案spa
sudo apt-get install libsm6
sudo apt-get install libxrender1
sudo apt-get install libxext-dev
複製代碼