Wednesday, 20 February 2019

Installing pygraphviz on Windows 10 64-bit, Python 3.6

Okay, here we go... I am trying to install pygraphviz on Windows 10. There are many solutions to this problem online, but none have yet worked for me. The precise problem I'm having is with this via jupyter notebook-->

[1] import networkx as nx
import pylab as plt
from networkx.drawing.nx_agraph import graphviz_layout

[2]G = nx.DiGraph()
G.add_node(1,level=1)
G.add_node(2,level=2)
G.add_node(3,level=2)
G.add_node(4,level=3)

G.add_edge(1,2)
G.add_edge(1,3)
G.add_edge(2,4)

nx.draw(G, pos=graphviz_layout(G), node_size=1600, cmap=plt.cm.Blues,
    node_color=range(len(G)),
    prog='dot')
plt.show()

I get the following errors after [2]:

ModuleNotFoundError                       Traceback (most recent call last)
C:\Users\name\Anaconda3\lib\site-packages\networkx\drawing\nx_agraph.py 
in 
pygraphviz_layout(G, prog, root, args)
    254     try:
--> 255         import pygraphviz
    256     except ImportError:

ModuleNotFoundError: No module named 'pygraphviz'

and

ImportError                               Traceback (most recent call last)
<ipython-input-2-86a15892f0f0> in <module>()
  9 G.add_edge(2,4)
 10 
---> 11 nx.draw(G, pos=graphviz_layout(G), node_size=1600, cmap=plt.cm.Blues,
 12         node_color=range(len(G)),
 13         prog='dot')

C:\Users\name\Anaconda3\lib\site-packages\networkx\drawing\nx_agraph.py in graphviz_layout(G, prog, root, args)
226 
227     """
--> 228     return pygraphviz_layout(G,prog=prog,root=root,args=args)
229 
230 def pygraphviz_layout(G,prog='neato',root=None, args=''):

C:\Users\name\Anaconda3\lib\site-packages\networkx\drawing\nx_agraph.py in pygraphviz_layout(G, prog, root, args)
256     except ImportError:
257         raise ImportError('requires pygraphviz ',
--> 258                           'http://pygraphviz.github.io/')
259     if root is not None:
260         args+="-Groot=%s"%root

ImportError: ('requires pygraphviz ', 'http://pygraphviz.github.io/')

Here's what I've tried to resolve this

(1) Regular pip install: "pip install pygraphviz" This is the error I get at the end. EDIT I get the same error even if I run cmd as admin.

Command "C:\Users\name\Anaconda3\python.exe -u -c "import setuptools, 
tokenize;__file__='C:\\Users\\name~1\\AppData\\Local\\Temp\\pip-build-
n81lykqs\\pygraphviz\\setup.py';f=getattr(tokenize, 'open', open)
(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, 
__file__, 'exec'))" install --record C:\Users\name~1\AppData\Local\Temp\pip-
b3jz1lk5-record\install-record.txt --single-version-externally-managed --
compile" failed with error code 1 in C:\Users\name~1\AppData\Local\Temp\pip-
build-n81lykqs\pygraphviz\

(2) Downloading and installing graphviz-2.38.msi, and then downloading both the 64-bit versions of the wheel. This is the result.

C:\Users\name\Anaconda3>pip install pygraphviz-1.3.1-cp34-none-
win_amd64.whl
pygraphviz-1.3.1-cp34-none-win_amd64.whl is not a supported wheel on this 
platform.

C:\Users\name\Anaconda3>pip install pygraphviz-1.3.1-cp27-none-
win_amd64.whl
pygraphviz-1.3.1-cp27-none-win_amd64.whl is not a supported wheel on this 
platform.

What I would like to try, but am not sure how to do properly:

Edit setup.py. I have read a lot about people finding solutions in changing the paths, but I'm not really sure how to do this. This method looks very complex.

Thank you for any help/insight!



from Installing pygraphviz on Windows 10 64-bit, Python 3.6

No comments:

Post a Comment