No module named _graphviz
Question: I installed graphviz and pygraphviz, when I open a cmd and type

    
    
    python
    import _graphviz
    

_graphviz can be imported, but when I run a C++ program which will invoke a
.py file, there is a line in this .py file which is

    
    
    import pygraphviz as pgv
    

Then it will not be able to import _graphviz, it shows the following info:

    
    
    Traceback (most recent call last):
      File "E:\project\graph\analysis\x64\Debug\gengraph.py", line 1, in <module>
        import pygraphviz as pgv
      File "C:\Program Files\Python27\lib\site-packages\pygraphviz\__init__.py", lin
    e 54, in <module>
        from agraph import AGraph, Node, Edge, Attribute, ItemAttribute
      File "C:\Program Files\Python27\lib\site-packages\pygraphviz\agraph.py", line
    20, in <module>
        import graphviz as gv
      File "C:\Program Files\Python27\lib\site-packages\pygraphviz\graphviz.py", lin
    e 7, in <module>
        import _graphviz
    ImportError: No module named _graphviz
    

Can you help me, any advice is welcome, thank you!


Answer: What system are you using? I spent a good 4 hours trying to figure it out on
Windows but ended up migrating my project to Ubuntu. From what I've learned,
it's caused by the program not finding the pygraphviz file. It searches in
this sequence on Windows: 1,register; 2,PATH; 3,folders. Some methods
availables:

**Find the block in setup.py for register and skip it.**

**Rename folder of pygraphviz installation(remove blanks) and move it to a
path without blanks**

In Ubuntu, you could simply "sudo easy-install pygraphviz" which worked for
me.

