我有一个相当奇怪的场景。我正在运行一个非常旧的安装,所以我编译了我使用的大部分工具。
首先,这是一台服务器。它专门用于SSH。但无论谁设置这台服务器都做出了一些奇怪的选择。登录时有一个名为fphyiscs的用户,而不是创建单独的用户,主目录为/ home / fphysics。 (严格通过公钥/私钥认证来控制访问。所以每个人都以“fphysics”身份登录,但没有密码。)然后在这个目录中有“profile”目录。例如,我的是/ home / fphysics / joelfred。有一个脚本由登录时的fphysics运行,它查看/ home / fphysics中的目录并将它们解释为“profile”。然后,您可以选择要使用的“配置文件”。然后,该脚本在此配置文件目录中提供名为“ENVS”的文件。
我觉得这很奇怪。但我知道最好不要与系统管理员争论。所以我在这个系统内工作。我设置我的ENVS来获取更传统的.bash_profile,而不是像他们想要的那样设置环境变量。我在ENVS中设置了我的HOME环境变量:export HOME = / home / fphysics / joelfred。这个系统上的软件已经过时了,我用$ HOME / opt的前缀编译了很多我自己的东西。所以我的路径现在包括$ HOME / opt / bin。我将/home/fphysics/.Xauthority与/home/fphyiscs/joelfred/.Xauthority联系起来,因此x会话通过SSH工作。老实说,我不记得我为使这项工作更正常所做的所有黑客事情,所以我可以访问更多当前的软件。 (例如,GCC是v4.1.2,版权所有2006。)
我已经尝试使用GTK3Agg后端编译和安装Matplotlib。当然,这意味着我必须编译很多x库,GTK,pygobject等等。在某些方面,我不得不编译DBUS。现在,我有一些有趣/恼人的Matplotlib行为。例如,这可以按预期工作:
fphysics@facet-srv01 ~$ ipython
Python 2.7.3 (default, Apr 30 2013, 00:58:45)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.2 -- 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.
In [1]: import matplotlib.pyplot as plt
** (ipython:1648): WARNING **: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-oWyQu0DxxF: Connection refused
In [2]: import numpy as np
In [3]: x=np.linspace(-10,10,100)
In [4]: y=x*x
In [5]: plt.plot(x,y)
Out[5]: [<matplotlib.lines.Line2D at 0xacb2eec>]
In [6]: plt.show()
这按预期工作 - 我得到一个抛物线图。我有一个阻止我的ipython终端的窗口。据我所知,窗口具有完整功能。当我关闭它时,我会回到我的ipython终端。注意奇怪的dbus错误 - 我没有IDEA获得/ tmp / dbus-oWyQu0DxxF的想法。我看了,我不明白。
好。所以现在我想打开交互模式:
fphysics@facet-srv01 ~$ ipython
Python 2.7.3 (default, Apr 30 2013, 00:58:45)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.2 -- 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.
In [1]: import matplotlib.pyplot as plt
** (ipython:4181): WARNING **: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-oWyQu0DxxF: Connection refused
In [2]: import numpy as np
In [3]: plt.ion()
In [4]: x=np.linspace(-10,10,100)
In [5]: y=x*x
In [6]: plt.plot(x,y)
Out[6]: [<matplotlib.lines.Line2D at 0xb0f1fcc>]
我一无所获。奇怪的。我试一下节目:
In [7]: plt.show()
无。我试了一下:
In [8]: plt.draw()
我得到一个标题为“图1”的窗口,但它是灰色的。我尝试了另一个平局:
In [9]: plt.draw()
现在我用抛物线给了一个窗口。但没有按钮工作。我甚至无法关闭窗户。所以我试着结束:
In [10]: plt.close()
什么都没发生。好的。我将退出我的ipython终端:
In [11]: exit
窗户消失,没有错误。但是如果我不做演出或平局或退出会发生什么?我得到了奇怪的错误:
fphysics@facet-srv01 ~$ ipython
Python 2.7.3 (default, Apr 30 2013, 00:58:45)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.2 -- 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.
In [1]: import matplotlib.pyplot as plt
** (ipython:7262): WARNING **: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-oWyQu0DxxF: Connection refused
In [2]: import numpy as np
In [3]: plt.ion()
In [4]: x=np.linspace(-10,10,100)
In [5]: y=x*x
In [6]: plt.plot(x,y)
Out[6]: [<matplotlib.lines.Line2D at 0xb636bf6c>]
In [7]: exit
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/home/fphysics/joelfred/opt/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/fphysics/joelfred/opt/lib/python2.7/site-packages/matplotlib/_pylab_helpers.py", line 87, in destroy_all
manager.destroy()
File "/home/fphysics/joelfred/opt/lib/python2.7/site-packages/matplotlib/backends/backend_gtk3.py", line 415, in destroy
self.canvas.destroy()
AttributeError: FigureManagerGTK3Agg instance has no attribute 'canvas'
Error in sys.exitfunc:
Traceback (most recent call last):
File "/home/fphysics/joelfred/opt/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/fphysics/joelfred/opt/lib/python2.7/site-packages/matplotlib/_pylab_helpers.py", line 87, in destroy_all
manager.destroy()
File "/home/fphysics/joelfred/opt/lib/python2.7/site-packages/matplotlib/backends/backend_gtk3.py", line 415, in destroy
self.canvas.destroy()
AttributeError: FigureManagerGTK3Agg instance has no attribute 'canvas'
所以我挖到了dbus - 我能看到的唯一可能影响事情的错误。我显然有两个装置:
fphysics@facet-srv01 ~$ $HOME/opt/bin/dbus-daemon --version
D-Bus Message Bus Daemon 1.7.2
Copyright (C) 2002, 2003 Red Hat, Inc., CodeFactory AB, and others
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
fphysics@facet-srv01 ~$ /bin/dbus-daemon --version
D-Bus Message Bus Daemon 1.1.2
Copyright (C) 2002, 2003 Red Hat, Inc., CodeFactory AB, and others
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
也许他们在竞争?我不知道。我已将/home/fphysics/.dbus符号链接到/home/fphysics/joelfred/.dbus。这似乎没有帮助。我不知所措。我不知道是怎么回事。我该如何诊断?如何让dbus在我的场景中工作?我如何在更基础的水平上测试它?世界上到底发生了什么?
顺便说一句,Ipython使测试更容易,但如果我从python提示符运行,行为是相同的。