0

Can some one please help me with this error. I am using Ubuntu 20.04 and jupyter notebook. (I have directly installed project jupyter from ubuntu app store. I don't have anaconda installed with it or spyder.)

I have tried following but nothing worked at

!pip install opencv-python

sudo apt-get install python3-opencv

apt update && apt install -y libsm6 libxext6 libxrender-dev

Strange thing is if write the same code in other python file and run it through terminal it's working. But I am unable to run the same code in Jupyter Notebook

ImportError                               Traceback (most recent call last)
<ipython-input-1-c8ec22b3e787> in <module>
----> 1 import cv2

/home/adarsh/snap/jupyter/common/lib/python3.7/site-packages/cv2/__init__.py in <module>
      3 import sys
      4 
----> 5 from .cv2 import *
      6 from .data import *
      7 

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

2 Answers2

0

you can actually use jupyter notebook itself to install

conda install opencv
desertnaut
  • 57,590
  • 26
  • 140
  • 166
shyam_gupta
  • 309
  • 2
  • 11
0

Adding below lines infront of my code solved my problem

!pip install opencv-python-headless
# also contrib, if needed
!pip install opencv-contrib-python-headless
Adarsh
  • 116
  • 6