BoringBlue
文章14
标签17
分类6
记python安装cv2

记python安装cv2

随手记

python2.7

使用安装opencv-python替换cv2

    #安装:
    pip install opencv-python
    #安装指定版本
    pip install -U opencv-python==3.4.4.19

不行的话 可以升级到python3或者另外安装python3

python3

  • 安装python

      # 我这里安装的python3.6版本
      yum install python36
    
      # 查看python版本
      python3 -V
    
      # 查看pip版本
      pip3 show pip
    
      # pip升级
      pip3 install --upgrade pip
    
  • 安装cv2

      pip install cv2
      # 如果以上命令失败,可试试下面一条
      pip install opencv-python
    
  • 调试
    如果运行中遇到类似以下错误:

    from .cv2 import * ImportError: libGL.so.1: cannot open shared object file:

    yum install libglvnd-glx

    ImportError: libXrender.so.1: cannot open shared object file: No such file or directory

    yum install libXrender-devel.x86_64

    如果第一次执行失败,可能是opencv版本问题,可以修改opencv版本:
    pip install -U opencv-python==3.4.4.19

    ImportError: libSM.so.6: cannot open shared object file: No such file or directory

    yum install libSM-1.2.2-2.el7.x86_64

×