[Solved] import cv2 Error: ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Execute the following command:

    import cv2
  File "/appletree/miniconda3/envs/yyp_pytorch/lib/python3.7/site-packages/cv2/__init__.py", line 5, in <module>
    from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Reason: libGL.so.1 is missing.
Solution:
execute the following command after pip install opencv-python

pip install opencv-python-headless

Read More: