Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV installation Google Colab

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!

like image 807
Nikhil Mishra Avatar asked Nov 30 '22 14:11

Nikhil Mishra


2 Answers

OpenCV comes preinstalled on Google colab.

Simply import cv2 and use it.

enter image description here

like image 174
Biranchi Avatar answered Dec 04 '22 06:12

Biranchi


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.

like image 45
Bob Smith Avatar answered Dec 04 '22 05:12

Bob Smith