服务器安装opencv-python,并解决cv2依赖环境
pip install opencv-python
安装了opencv-python 之后,在使用 import cv2 报错如下
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
>>>
报错原因: 缺少共享库
Centos解决方案
yum whatprovides libSM.so.6
yum install libSM-1.2.2-2.el7.x86_64 --setopt=protected_multilib=false
Ubuntu解决方案
sudo apt-get install libsm6
sudo apt-get install libxrender1
sudo apt-get install libxext-dev