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.
source share