Automatic detection of display availability with matplotlib

后端 未结 7 1618
悲&欢浪女
悲&欢浪女 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 07:12
    import os
    have_display = bool(os.environ.get('DISPLAY', None))
    

    have_display is False if DISPLAY is not in the environment or is an empty string. otherwise, it's True

    0 讨论(0)
提交回复
热议问题