Generating a PNG with matplotlib when DISPLAY is undefined

前端 未结 12 1482
感动是毒
感动是毒 2020-11-22 02:51

I am trying to use networkx with Python. When I run this program it get this error. Is there anything missing?

#!/usr/bin/env python

import networkx as nx
i         


        
12条回答
  •  半阙折子戏
    2020-11-22 03:07

    I got the error while using matplotlib through Spark. matplotlib.use('Agg') doesn't work for me. In the end, the following code works for me. More here

    import matplotlib.pyplot as plt.
    plt.switch_backend('agg')
    

提交回复
热议问题