python的display显示_python – TclError:在Windows 10 Bash上没有显示名称和没有$DISPLAY环境变量...

柳俊逸
2023-12-01

我试图在

Windows 10 Bash shell上安装matplotlib.

之后,我运行了以下几行:

$ipython3

然后

In[1]: %pylab

然后它给了我一个跟随错误:

---------------------------------------------------------------------------

TclError Traceback (most recent call last)

in ()

----> 1 get_ipython().magic('pylab')

/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py in magic(self, arg_s)

2164 magic_name, _, magic_arg_s = arg_s.partition(' ')

2165 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)

-> 2166 return self.run_line_magic(magic_name, magic_arg_s)

2167

2168 #-------------------------------------------------------------------------

/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line)

2085 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals

2086 with self.builtin_trap:

-> 2087 result = fn(*args,**kwargs)

2088 return result

2089

/usr/lib/python3/dist-packages/IPython/core/magics/pylab.py in pylab(self, line)

/usr/lib/python3/dist-packages/IPython/core/magic.py in (f, *a, **k)

190 # but it's overkill for just that one bit of state.

191 def magic_deco(arg):

--> 192 call = lambda f, *a, **k: f(*a, **k)

193

194 if isinstance(arg, collections.Callable):

/usr/lib/python3/dist-packages/IPython/core/magics/pylab.py in pylab(self, line)

129 import_all = not args.no_import_all

130

--> 131 gui, backend, clobbered = self.shell.enable_pylab(args.gui, import_all=import_all)

132 self._show_matplotlib_backend(args.gui, backend)

133 print ("Populating the interactive namespace from numpy and matplotlib")

/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py in enable_pylab(self, gui, import_all, welcome_message)

2918 from IPython.core.pylabtools import import_pylab

2919

-> 2920 gui, backend = self.enable_matplotlib(gui)

2921

2922 # We want to prevent the loading of pylab to pollute the user's

/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)

2879 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)

2880

-> 2881 pt.activate_matplotlib(backend)

2882 pt.configure_inline_support(self, backend)

2883

/usr/lib/python3/dist-packages/IPython/core/pylabtools.py in activate_matplotlib(backend)

244 matplotlib.rcParams['backend'] = backend

245

--> 246 import matplotlib.pyplot

247 matplotlib.pyplot.switch_backend(backend)

248

/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py in ()

2510 # are no-ops and the registered function respect `mpl.is_interactive()`

2511 # to determine if they should trigger a draw.

-> 2512 install_repl_displayhook()

2513

2514 ################# REMAINING CONTENT GENERATED BY boilerplate.py ##############

/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py in install_repl_displayhook()

163 ipython_gui_name = backend2gui.get(get_backend())

164 if ipython_gui_name:

--> 165 ip.enable_gui(ipython_gui_name)

166 else:

167 _INSTALL_FIG_OBSERVER = True

/usr/lib/python3/dist-packages/IPython/terminal/interactiveshell.py in enable_gui(gui, app)

306 from IPython.lib.inputhook import enable_gui as real_enable_gui

307 try:

--> 308 return real_enable_gui(gui, app)

309 except ValueError as e:

310 raise UsageError("%s" % e)

/usr/lib/python3/dist-packages/IPython/lib/inputhook.py in enable_gui(gui, app)

526 e = "Invalid GUI request %r, valid ones are:%s" % (gui, list(guis.keys()))

527 raise ValueError(e)

--> 528 return gui_hook(app)

529

/usr/lib/python3/dist-packages/IPython/lib/inputhook.py in enable_tk(self, app)

322 if app is None:

323 import tkinter

--> 324 app = tkinter.Tk()

325 app.withdraw()

326 self._apps[GUI_TK] = app

/usr/lib/python3.4/tkinter/__init__.py in __init__(self, screenName, baseName, className, useTk, sync, use)

1852 baseName = baseName + ext

1853 interactive = 0

-> 1854 self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)

1855 if useTk:

1856 self._loadtk()

TclError: no display name and no $DISPLAY environment variable

如果有人能指出如何删除此错误,我将不胜感激.谢谢.

 类似资料: