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

让人想犯罪 __ 提交于 2019-11-29 22:37:40

This fixed the problem by having it as the first two lines of the script:

!pip install opencv-python
!apt update && apt install -y libsm6 libxext6

You need to add sudo . I did the following to get it installed :

  • sudo apt-get install libsm6 libxrender1 libfontconfig1

and then did that

  • sudo python3 -m pip install opencv-contrib-python

FINALLY got it done !

For CentOS, run this: sudo yum install libXext libSM libXrender

Credoz

May be the problem is with your python-opencv version. It's better to downgrade your version to 3.3.0.9 which does not include any GUI dependencies. Same question was found on GitHub here the link to the answer.

There is now a headless version of opencv-python which removes the graphical dependencies (like libSM). You can see the normal / headless version on the releases page (and the GitHub issue leading to this); just add -headless when installing, e.g.,

pip install opencv-python-headless
# also contrib, if needed
pip install opencv-contrib-python-headless

I was facing similar issue with openCV on the python:3.7-slim docker box. Following did the trick for me :

apt-get build-essential libglib2.0-0 libsm6 libxext6 libxrender-dev

Please see if this helps !

I was not able to install cv2 on Anaconda-Jupyter notebook running on Ubuntu on Google Cloud Platform. But I found a way to do it as follows:

Run the following command from the ssh terminal and follow the instruction:

 sudo apt-get install libsm6 libxrender1 libfontconfig1

Once its installed Open the Jupyter notebook and run following command:

!pip install opencv-contrib-python

Note: I tried to run this command: "sudo python3 -m pip install opencv-contrib-python"but it was showing an error. But above command worked for me.

Now refresh the notebook page and check whether it's installed or not by running import cv2 in the notebook.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!