Automatic detection of display availability with matplotlib

后端 未结 7 1662
悲&欢浪女
悲&欢浪女 2020-12-15 06:26

I\'m generating matplotlib figures in a script which I run alternatively with or without a graphical display. I\'d like the script to adjust automatically: with display, it

7条回答
  •  别那么骄傲
    2020-12-15 06:53

    You can detect directly if you have a display with the OS module in python. in my case it's

    >>> import os
    >>> os.environ["DISPLAY"]
    ':0.0'
    

提交回复
热议问题