title: What could cause NetworkX & PyGraphViz to work fine alone but not together?
body: <p>I'm working to learning some Python graph visualization. I found a few blog posts doing <a href="https://kenmxu.wordpress.com/2013/06/12/network-x-4-8-2/" rel="noreferrer">some</a> <a href="http://www.randomhacks.net/2009/12/29/visualizing-wordnet-relationships-as-graphs/" rel="noreferrer">things</a> I wanted to try. Unfortunately I didn't get too far, encountering this error: <code>AttributeError: 'module' object has no attribute 'graphviz_layout'</code></p>
  
  <p>The simplest snip of code which <strong>reproduces the error</strong> on my system is this,</p>
  
  <pre><code>In [1]: import networkx as nx
  In [2]: G=nx.complete_graph(5)
  In [3]: nx.draw_graphviz(G)
  ------------------------------------------------------------
  AttributeError Traceback (most recent call last)
  &amp;lt;ipython-input-3-481ad1c1771c&amp;gt; in &amp;lt;module&amp;gt;()
  ----&amp;gt; 1 nx.draw_graphviz(G)
  /usr/lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyc in draw_graphviz(G, prog, **kwargs)
  982 See networkx.draw_networkx() for a description of optional keywords.
  983 """
  --&amp;gt; 984 pos = nx.drawing.graphviz_layout(G, prog)
  985 draw(G, pos, **kwargs)
  986
  AttributeError: 'module' object has no attribute 'graphviz_layout'
  </code></pre>
  
  <p>I found a similar <a href="https://stackoverflow.com/questions/33859001/how-do-you-get-networkx-graphviz-layout-to-work">questions</a>, and <a href="http://www.jhreview.com/tech-stack/questions/22698227/python-installation-issues-with-pygraphviz-and-graphviz" rel="noreferrer">posts</a> having difficulty with this combo, but not quite the same error. One was <a href="https://stackoverflow.com/questions/32587445/drawing-graph-in-graphviz-layout-in-python-using-nx-draw-graphviz-gives-error">close</a>, but it automagically resolved itself.</p>
  
  <p><strong>First, I verified all the required packages</strong> for <a href="https://networkx.readthedocs.org/en/stable/install.html#requirements" rel="noreferrer">NetworkX</a> and PyGraphViz (which lists similar requirements to <a href="http://scipy.org/install.html#individual-binary-and-source-packages" rel="noreferrer">Scipy</a>) were installed. </p>
  
  <p><strong>Next, I looked for snips to test my installation of these modules in Python.</strong> The first two examples are from the <a href="https://networkx.readthedocs.org/en/stable/reference/drawing.html#module-networkx.drawing.nx_agraph" rel="noreferrer">NetworkX Reference Documentation</a>. This lists a few example snips using both MatPlotLib and GraphViz. </p>
  
  <p><strong>The MatPlotLib code example works for me (renders an image to the screen)</strong>,</p>
  
  <pre><code>In [11]: import networkx as nx
  In [12]: G=nx.complete_graph(5)
  In [13]: import matplotlib.pyplot as plt
  In [13]: nx.draw(G)
  In [13]: plt.show()  
  </code></pre>
  
  <p>However, the <strong>GraphViz snips also produce similar errors,</strong></p>
  
  <pre><code>In [16]: import networkx as nx
  In [17]: G=nx.complete_graph(5)
  In [18]: H=nx.from_agraph(A)
  ------------------------------------------------------------
  AttributeError Traceback (most recent call last)
  &lt;ipython-input-18-808fa68cefaa&gt; in &lt;module&gt;()
  ----&gt; 1 H=nx.from_agraph(A)
  AttributeError: 'module' object has no attribute 'from_agraph'
  In [19]: A=nx.to_agraph(G)
  ------------------------------------------------------------
  AttributeError Traceback (most recent call last)
  &lt;ipython-input-19-32d1616bb41a&gt; in &lt;module&gt;()
  ----&gt; 1 A=nx.to_agraph(G)
  AttributeError: 'module' object has no attribute 'to_agraph'
  In [20]: print G
  complete_graph(5)
  </code></pre>
  
  <p><strong>Then I tried PyGraphViz's tutorial page</strong> on <a href="http://pygraphviz.github.io/documentation/development/tutorial.html#layout-and-drawing" rel="noreferrer">Layout &amp; Drawing</a>. This has some snips as well. <strong>PyGraphViz passed</strong> with Neato (default), PyDot, and Circo Post Script output (viewed using Gimp). (The only difference is these PyGraphViz examples are not rendered to the display, but to files).</p>
  
  <pre><code>In [1]: import pygraphviz as pgv
  In [2]: d={'1': {'2': None}, '2': {'1': None, '3': None}, '3': {'2': None}}
  In [3]: A=pgv.AGraph(d)
  In [4]: A.write("pygraphviz_test_01.dot")
  In [5]: A.layout()
  In [6]: A.draw('pygraphviz_test_01.png')
  </code></pre>
  
  <p><strong>Adding to the complexity,</strong> PyGraphViz <a href="http://pygraphviz.github.io/documentation/pygraphviz-1.3rc1/install.html#requirements" rel="noreferrer">requires GraphViz</a> package binaries in order to work. I'm using Arch Linux, and installed that distro's version. Arch Linux has an <a href="https://wiki.archlinux.org/index.php/Graphviz" rel="noreferrer">example to test installation</a> (again, output to file) <strong>which also passed</strong>.</p>
  
  <p>What am I missing? <strong>What could cause NetworkX &amp; PyGraphViz to work fine alone but not together?</strong></p>