Matplotlib ipython--cygwin上的pylab:TclError:没有显示名称和$display环境变量

Matplotlib ipython--cygwin上的pylab:TclError:没有显示名称和$display环境变量,matplotlib,cygwin,tkinter,ipython,Matplotlib,Cygwin,Tkinter,Ipython,我最近按照以下说明安装了ipython: 当我运行'ipython--pylab'时,我得到下面的错误消息。我在谷歌上搜索过,找到了关于这个错误的帖子,但内容不同。当我使用--pylab参数启动ipython时,会发生我的错误。我知道这与matplotlib gui交互有关,但不确定具体是什么。我感谢你的指导 $ ipython --pylab Python 2.7.3 (default, Dec 18 2012, 13:50:09) Type "copyright", "credits" or

我最近按照以下说明安装了ipython:

当我运行
'ipython--pylab'
时,我得到下面的错误消息。我在谷歌上搜索过,找到了关于这个错误的帖子,但内容不同。当我使用--pylab参数启动ipython时,会发生我的错误。我知道这与matplotlib gui交互有关,但不确定具体是什么。我感谢你的指导

$ ipython --pylab
Python 2.7.3 (default, Dec 18 2012, 13:50:09)
Type "copyright", "credits" or "license" for more information.

IPython 0.13.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

Welcome to pylab, a matplotlib-based Python environment [backend: TkAgg].
For more information, type 'help(pylab)'.
[TerminalIPythonApp] GUI event loop or pylab initialization failed
---------------------------------------------------------------------------
TclError                                  Traceback (most recent call last)
/usr/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_pylab(self, gui, import_all)
   2780         # Now we must activate the gui pylab wants to use, and fix %run to take
   2781         # plot updates into account
-> 2782         self.enable_gui(gui)
   2783         self.magics_manager.registry['ExecutionMagics'].default_runner = \
   2784         mpl_runner(self.safe_execfile)

/usr/lib/python2.7/site-packages/IPython/lib/inputhook.pyc in enable_gui(gui, app)
    526         e = "Invalid GUI request %r, valid ones are:%s" % (gui, guis.keys())
    527         raise ValueError(e)
--> 528     return gui_hook(app)
    529

/usr/lib/python2.7/site-packages/IPython/lib/inputhook.pyc 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/python2.7/lib-tk/Tkinter.pyc in __init__(self, screenName, baseName, className, useTk, sync, use)
   1683                 baseName = baseName + ext
   1684         interactive = 0
-> 1685         self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
   1686         if useTk:
   1687             self._loadtk()

TclError: no display name and no $DISPLAY environment variable

在cygwin终端中键入
startxwin
(您需要cygwin setup.exe中提供的X11库),然后可以从新终端窗口运行
ipython--pylab
,以及类似
plot(range(10))
的命令,该命令将打开一个新窗口,但您还需要调用
plt.draw()
与本机pylab不同的是,cygwin中的绘图窗口控制也不如本机pylab

在此过程中,我不需要编辑任何安装文件,您可能需要“pip uninstall matplotlib”并重新安装,直到通过cygwin setup.exe安装了所需的库(tkinter和我认为X11 devel库是必需的)

通过ez_setup.py获取setuptools

wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
easy_install pip 
pip install numpy 
pip install ipython
pip install matplotlib

我不知道tkinter和cygwin是否兼容。你需要使用cygwin吗?您可以在Windows上安装IPython和matplotlib,而无需cygwin。感谢您的反馈。我对cygwin还有其他依赖性,这就是为什么我希望与运行时环境保持一致。我上面引用的带有安装说明的网站似乎表明ipython和matplotlib应该与cygwin一起使用,因为这些说明是针对cygwin的。现在看来,您需要在cygwin中为tkinter安装X11-链接的帖子可能使用的是旧版本。这与X/Cygwin()相同吗?我刚安装,但出现了相同的错误:(对不起,那么你得希望对Cygwin有更多了解的人能帮上忙。