Generating a PNG with matplotlib when DISPLAY is undefined

前端 未结 12 1250
感动是毒
感动是毒 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:01

    Just as a complement of Reinout's answer.

    The permanent way to solve this kind of problem is to edit .matplotlibrc file. Find it via

    >>> import matplotlib
    >>> matplotlib.matplotlib_fname() # This is the file location in Ubuntu '/etc/matplotlibrc'

    Then modify the backend in that file to backend : Agg. That is it.

提交回复
热议问题