linux 安装opencv-python 导入cv2的时候报错

报错日志:

>>> import cv2
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/cheung/anaconda3/lib/python3.7/site-packages/cv2/__init__.py", line 3, in 
    from .cv2 import *
ImportError: libSM.so.6: cannot open shared object file: No such file or directory

报错原因: 缺少共享库
解决方法:

  1. 查看缺少什么库:
命令: yum whatprovides libSM.so.6
响应: 
(base) [root@VM_30_16_centos machine]# yum whatprovides libSM.so.6
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
libSM-1.2.2-2.el7.i686 : X.Org X11 SM runtime library
  1. 安装缺少的库
 yum install libSM-1.2.2-2.el7.x86_64 --setopt=protected_multilib=false
  1. 查看问题是否解决
>>> import cv2
>>> quit()

你可能感兴趣的:(linux 安装opencv-python 导入cv2的时候报错)