title: Matplotlib won't plot: dbus issue?
body: <p>I have a rather strange scenario.  I'm running on a very old installation, so I've compiled most of the tools I use.</p>
  
  <p>First, this is a server.  It is exclusively used by SSH-ing into it.  But whoever set this server up made some strange choices.  Instead of creating separate users, there is one user on login called fphyiscs, with a home directory of /home/fphysics.  (Access is controlled strictly via public key/private key authentication.  So everybody logs in as "fphysics", but there are no passwords.)  Then there are "profile" directories in this one.  For instance, mine is /home/fphysics/joelfred.  There is a script that is run by fphysics on login that looks through the directories in /home/fphysics and interprets these as "profile".  You can then choose which "profile" you want to use.  The script then sources a file called "ENVS" in this profile directory.</p>
  
  <p>I thought this was weird.  But I know better than to argue with a sysadmin.  So I work within this system.  I set up my ENVS to source a more conventional .bash_profile, instead of just setting up environment variables as they probably intended.  I set my HOME environment variable in ENVS: export HOME=/home/fphysics/joelfred.  The software on this system is so outdated that I've compiled tons of my own stuff, using a prefix of $HOME/opt.  So my path now includes $HOME/opt/bin.  I sym-linked /home/fphysics/.Xauthority to /home/fphyiscs/joelfred/.Xauthority, so x sessions work over SSH.  I honestly don't remember all the hacky things I've done to make this work more normally, and so I can have access to more current software.  (For instance, GCC is v4.1.2, copyright 2006.)</p>
  
  <p>I've since tried to compile and install Matplotlib, with the GTK3Agg backend.  This means, of course, that I had to compile a lot of x libraries, GTK, pygobject, etc., etc.  At some point along the line, I had to compile DBUS.  Now, I have some interesting/annoying Matplotlib behavior.  This, for instance, works as expected:</p>
  
  <pre><code>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.
  ?         -&gt; Introduction and overview of IPython's features.
  %quickref -&gt; Quick reference.
  help      -&gt; Python's own help system.
  object?   -&gt; 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]: [&lt;matplotlib.lines.Line2D at 0xacb2eec&gt;]
  
  In [6]: plt.show()
  </code></pre>
  
  <p>This works as expected - I get a plot of a parabola.  I get a window that blocks my ipython terminal.  The window, as far as I can tell, has full functionality.  When I close it, I get returned to my ipython terminal.  Note the strange dbus error though - I have NO IDEA where it gets the /tmp/dbus-oWyQu0DxxF idea.  I've looked and I don't get it.</p>
  
  <p>Okay.  So now I want to turn on interactive mode:</p>
  
  <pre><code>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.
  ?         -&gt; Introduction and overview of IPython's features.
  %quickref -&gt; Quick reference.
  help      -&gt; Python's own help system.
  object?   -&gt; 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]: [&lt;matplotlib.lines.Line2D at 0xb0f1fcc&gt;]
  </code></pre>
  
  <p>I get nothing.  Weird.  I try a show:</p>
  
  <pre><code>In [7]: plt.show()
  </code></pre>
  
  <p>Nothing.  I try a draw:</p>
  
  <pre><code>In [8]: plt.draw()
  </code></pre>
  
  <p>I get a window with a title of "Figure 1", but it's gray.  I try another draw:</p>
  
  <pre><code>In [9]: plt.draw()
  </code></pre>
  
  <p>Now I get a window with my parabola.  But no buttons work.  I can't even close the window.  So I try a close:</p>
  
  <pre><code>In [10]: plt.close()
  </code></pre>
  
  <p>Nothing happens.  Okay.  I'll exit my ipython terminal:</p>
  
  <pre><code>In [11]: exit
  </code></pre>
  
  <p>Window goes away, no errors.  But what happens if I don't do a show or a draw or just exit?  I get weird errors:</p>
  
  <pre><code>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.
  ?         -&gt; Introduction and overview of IPython's features.
  %quickref -&gt; Quick reference.
  help      -&gt; Python's own help system.
  object?   -&gt; 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]: [&lt;matplotlib.lines.Line2D at 0xb636bf6c&gt;]
  
  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'
  </code></pre>
  
  <p>So I dug into dbus - the only error I can see that may be affecting things.  I have two installations apparently:</p>
  
  <pre><code>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.
  </code></pre>
  
  <p>Maybe they're competing?  I don't know.  I've symlinked /home/fphysics/.dbus to /home/fphysics/joelfred/.dbus.  That doesn't seem to help.  I'm at a loss.  I have no idea what's going on.  How do I diagnose this?  How do I get dbus to work in my scenario?  How do I test it on a more basic level?  What in the world is going on??</p>
  
  <p>BTW, Ipython makes the testing easier, but the behavior is the same if I run from a python prompt.</p>