python runtime错误_[Python] RuntimeError: Invalid DISPLAY variable

def use(arg, warn=True, force=False):"""Set the matplotlib backend to one of the known backends.

The argument is case-insensitive. *warn* specifies whether a

warning should be issued if a backend has already been set up.

*force* is an **experimental** flag that tells matplotlib to

attempt to initialize a new backend by reloading the backend

module.

.. note::

This function must be called *before* importing pyplot for

the first time; or, if you are not using pyplot, it must be called

before importing matplotlib.backends. If warn is True, a warning

is issued if you try and call this after pylab or pyplot have been

loaded. In certain black magic use cases, e.g.

:func:`pyplot.switch_backend`, we are doing the reloading necessary to

make the backend switch work (in some cases, e.g., pure image

backends) so one can set warn=False to suppress the warnings.

To find out which backend is currently set, see

:func:`matplotlib.get_backend`."""

#Lets determine the proper backend name first

if arg.startswith('module://'):

name=argelse:#Lowercase only non-module backend names (modules are case-sensitive)

arg =arg.lower()

name=validate_backend(arg)#Check if we've already set up a backend

if 'matplotlib.backends' insys.modules:#Warn only if called with a different name

if (rcParams['backend'] != name) andwarn:

warnings.warn(_use_error_msg)#Unless we've been told to force it, just return

if notforce:returnneed_reload=Trueelse:

need_reload=False#Store the backend name

rcParams['backend'] =name#If needed we reload here because a lot of setup code is triggered on

#module import. See backends/__init__.py for more detail.

ifneed_reload:

reload(sys.modules['matplotlib.backends'])

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值