0

[the image shows the error when I try to install pygraphviz][1]I created a network with PLG2 software and saved it in the .dot format, how can I switch from this to networkx graph?

from networkx.drawing import nx_agraph
from node2vec import Node2Vec
dotFormat= pydot.graph_from_dot_file(r'path')
def read_dot(dotFormat):
    try:
        import pygraphviz
    except ImportError:
        raise ImportError('read_dot() requires pygraphviz ',
                          'http://pygraphviz.github.io/')
    A=pygraphviz.AGraph(file=dotFormat)
    G = nx_agraph.from_agraph(pygraphviz.AGraph(dotFormat))  ```


  [1]: https://i.stack.imgur.com/LuI65.png
This is the error when I try to install pygraphviz on Pycharm on Windows10 with Python 3.6
'''    Command "C:\Users\Admin1\AppData\Local\Programs\Python\Python37-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Admin1\\AppData\\Local\\Temp\\pycharm-packaging\\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\Admin1\AppData\Local\Temp\pip-record-59rpzl5r\install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in C:\Users\Admin1\AppData\Local\Temp\pycharm-packaging\pygraphviz\
You are using pip version 10.0.1, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command   '''.

  • Can you please provide some information about what happens when you run the above code? – CJ Sullivan May 09 '19 at 18:11
  • when I execute the code it should transform the graphic into pydot format in networkx, but even if it results from the process 0 it does not transform the network. – Erika Falcone May 10 '19 at 09:20
  • OK, but is it giving you some particular error or just not writing data or something else? – CJ Sullivan May 10 '19 at 19:35
  • Does not give me errors in the code, the only error does not make me install pygraphviz on pycharm. I don't know why. How can i install it? – Erika Falcone May 11 '19 at 11:35
  • While it would help to see the exact pygraphviz error (there are tons of problems with pygraphviz installation), the general method would be [here](http://pygraphviz.github.io/documentation/pygraphviz-1.5/install.html). But please link in the pygraphviz error because that will help us debug mroe. – CJ Sullivan May 11 '19 at 19:40
  • I added the image that contains my error,Thanks for your help – Erika Falcone May 12 '19 at 10:10
  • That image does not actually get to the error part. Can you please copy and paste the error text into this question? I suspect you have a pygraphviz install problem, but the text for that will be below what you have shown here. – CJ Sullivan May 13 '19 at 16:08
  • I added part of the error – Erika Falcone May 17 '19 at 14:31
  • This install problem is already describe [here](https://stackoverflow.com/questions/38037013/pygraphviz-import-error-with-pycharm). – CJ Sullivan May 18 '19 at 16:04

1 Answers1

1

The from_pydot method of networkx is probably exact the method you need.

As mentioned in the documentation, you should be aware, that it will return a MultiGraph.

Sparky05
  • 4,692
  • 1
  • 10
  • 27