ImportError: libSM.so.6: cannot open shared objects file: no such file or directory

When I try to import OpenCV using import cv2 , I get the following error:

 /usr/local/lib/python2.7/dist-packages/cv2/__init__.py in <module>() 7 8 # make IDE (PyCharm) autocompletion happy ----> 9 from .cv2 import * 10 11 # wildcard import above does not import "private" variables like __version__ ImportError: libSM.so.6: cannot open shared object file: No such file or directory 

I don’t know how to fix it, trying to play with the new Colaboratory tool. The laptop is here: https://drive.google.com/file/d/0B7-sJqBiyjCcRmFkMzl6cy1iN0k/view?usp=sharing

+67
source share
7 answers

This fixed the problem when it was the first two lines of the script:

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

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

  • sudo apt-get install libsm6 libxrender1 libfontconfig1

and then did it

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

FINALLY did it!

+36
source

For CentOS, do the following: sudo yum install libXext libSM libXrender

+23
source

There may be a problem in your version of python-opencv . It is better to downgrade your version to 3.3.0.9, which does not include any graphical dependencies. The same question was found on GitHub here is a link to the answer .

+20
source

There is currently a headless version of opencv-python that removes graphical dependencies (e.g. libSM). You can see the normal / headless version on the releases page (and the GaHub issue leading to this); just add -headless when installing for example

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

I was unable to install cv2 on an Anaconda-Jupyter laptop running in Ubuntu on the Google Cloud Platform. But I found a way to do this as follows:

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

  sudo apt-get install libsm6 libxrender1 libfontconfig1 

After installing it, open the Jupyter notebook and run the following command:

 !pip install opencv-contrib-python 

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

Now refresh the notebook page and check if it is installed or not by running import cv2 in the notebook.

0
source

I came across a similar problem with openCV on a python:3.7-slim docking station python:3.7-slim . The following helped me:

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

Please see if this helps!

0
source

Source: https://habr.com/ru/post/1273117/


All Articles