import matplotlib.pyplot as plt
is erroring with python2.7, anaconda3.
The error is ImportError: libGL.so.1: cannot open shared object file: No su
Answer by Dhanisha works fine, as i am adding explanation on top off it
remove
import matplotlib.pyplot as plt
add
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
The reason behind such behavior is if you are running it on server switch do not have gui support or non interactive mode. If you run same code on jupyter notebook, it would work fine.
see below links
https://matplotlib.org/faq/howto_faq.html
https://github.com/matplotlib/matplotlib/issues/9954
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
this worked for me
Below commands worked for me:
sudo apt update
sudo apt install libgl1-mesa-glx