交互式matplotlib over ssh崩溃,Anaconda Scientific Python Distribution

时间:2014-09-16 17:27:39

标签: python ssh matplotlib anaconda

我已经在远程Mac OS 10.8.5机器上安装了Anaconda,我正在尝试将matplotlib图形转发回我的本地机器,但是IPython一直试图使用远程机器的原生图形并崩溃。还有其他人经历过这个吗?我可以用旧的Enthought Python Distribution(EPD)做到这一点,所以我知道所涉及的机器都是为它设置的。

我问了这个问题elsewhere,但没有运气。谢谢你的帮助。

localmachine:~ me$ ssh -Y remotemachine
Password:
Last login: Fri Sep 12 10:46:08 2014 from localmachine

remotemachine:~ me$ ipython
Python 2.7.8 |Anaconda 2.0.1 (x86_64)| (default, Aug 21 2014, 15:21:46) 
Type "copyright", "credits" or "license" for more information.

IPython 2.2.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
?         -> 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.

In [1]: import matplotlib

In [2]: import matplotlib.pyplot as plt

In [3]: plt.rcParams['backend']
Out[3]: 'TkAgg'

In [4]: matplotlib.use('TkAgg')

In [5]: plt.plot([1,2],[3,4])
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
CGColor with 0 components
/Users/me/anaconda/bin/python.app: line 3: 80244 Abort trap: 6           /Users/me/anaconda/python.app/Contents/MacOS/python "$@"

1 个答案:

答案 0 :(得分:0)

从Anaconda 2.0,Continuum stopped linking tk with X11开始,然后链接到Cocoa,这使得尝试转发网络图形会使解释器崩溃。当我将tk降级到链接到X11的最后一个版本时,使用TkAgg后端的交互式matplotlib的网络转发再次起作用:

conda install tk=8.5.13

缺点是现在我无法再升级/安装任何试图更新tk的东西。此外,Qt4Agg交互式后端仍然会使解释器崩溃。我想,这是向前迈出的一步。

编辑:我发现你可以按特定版本固定套餐,描述为here