import matplotlib.pyplot as plt, ImportError: libGL.so.1: cannot open shared object file: No such file or directory

后端 未结 3 909
栀梦
栀梦 2020-12-31 20:32

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

3条回答
  •  清酒与你
    2020-12-31 21:04

    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

提交回复
热议问题