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

后端 未结 3 901
栀梦
栀梦 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

    0 讨论(0)
  • 2020-12-31 21:13
    import matplotlib 
    matplotlib.use("Agg") 
    import matplotlib.pyplot as plt
    

    this worked for me

    0 讨论(0)
  • 2020-12-31 21:20

    Below commands worked for me:

    sudo apt update
    sudo apt install libgl1-mesa-glx
    
    0 讨论(0)
提交回复
热议问题