4
votes

I am trying to install OpenCV in google colab notebook. The official documentation says to do:

!apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-python
import cv2

The first statement works fine and installs everything. But on importing cv2 I am getting an error saying:

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

Any fix for this issue? Thanks for help!

3

3 Answers

6
votes

I can't reproduce this issue. The snippet above seems to work fine. https://colab.research.google.com/notebook#fileId=1OnUy6eFE7XhdfGfAHDCqQxpwueTOj_NO

Perhaps try restarting your backend via the Runtime -> Restart runtime menu.

12
votes

OpenCV comes preinstalled on Google colab.

Simply import cv2 and use it.

enter image description here

1
votes

Use Python 3.x.x version. it works, I checked it.