To commemorate the successful installation of pygraphviz after one day, download pygraphviz
The teacher gave us a python file for us to understand.
Import pygraphviz as pgv
In order to allow the program to run on its own computer, I used pip install pygraphviz to install it as usual. Then, what I was forced to do was to report various errors.
Then download the package (https://github.com/pygraphviz) on github, unzip it, and use python setup. py install
Error: fatal error: graphviz/cgraph. h: No such file
The solution found on stackoverflow is
Edit the setup. py file to add these locations as directories:
include_dirs = 'C:/Program Files (x86)/Graphviz2.38/include'
library_dirs = 'C:/Program Files (x86)/Graphviz2.38/lib'
At the same time I saw in readme, this need and Graphviz software used together, and I did not download, good drop, first to the official website to download the Graphviz-2.38
Directory added
Install again
Then the error becomes more:
$ python setup.py installlibrary_dirs=C:/Program Files (x86)/Graphviz2.38/lib/release/libinclude_dirs=C:/Program Files (x86)/Graphviz2.38/includerunning installrunning bdist_eggrunning egg_infowriting pygraphviz.egg-info\PKG-INFOwriting top-level names to pygraphviz.egg-info\top_level.txtwriting dependency_links to pygraphviz.egg-info\dependency_links.txtreading manifest file 'pygraphviz.egg-info\SOURCES.txt'reading manifest template 'MANIFEST.in'warning: no previously-included files matching '*~' found anywhere in distributionwarning: no previously-included files matching '*.pyc' found anywhere in distributionwarning: no previously-included files matching '.svn' found anywhere in distributionno previously-included directories found matching 'doc\build'writing manifest file 'pygraphviz.egg-info\SOURCES.txt'installing library code to build\bdist.win-amd64\eggrunning install_librunning build_pyrunning build_extbuilding 'pygraphviz._graphviz' extensionC:\Users\GJWood\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DGVDLL "-IC:/Program Files (x86)/Graphviz2.38/include" -Ic:\Users\GJWood\Anaconda\include -Ic:\Users\GJWood\Anaconda\PC /Tcpygraphviz/graphviz_wrap.c /Fobuild\temp.win-amd64-2.7\Release\pygraphviz/graphviz_wrap.objgraphviz_wrap.cpygraphviz/graphviz_wrap.c(3295) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of datapygraphviz/graphviz_wrap.c(3313) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of datapygraphviz/graphviz_wrap.c(3321) : warning C4047: 'return' : 'int' differs in levels of indirection from 'Agsym_t *'pygraphviz/graphviz_wrap.c(3407) : warning C4101: 'mode_byte_obj1' : unreferenced local variablepygraphviz/graphviz_wrap.c(3406) : warning C4101: 'mode_obj1' : unreferenced local variablepygraphviz/graphviz_wrap.c(3408) : warning C4101: 'mode1' : unreferenced local variablepygraphviz/graphviz_wrap.c(3405) : warning C4101: 'fd1' : unreferenced local variablepygraphviz/graphviz_wrap.c(3466) : warning C4101: 'mode2' : unreferenced local variablepygraphviz/graphviz_wrap.c(3464) : warning C4101: 'mode_obj2' : unreferenced local variablepygraphviz/graphviz_wrap.c(3463) : warning C4101: 'fd2' : unreferenced local variablepygraphviz/graphviz_wrap.c(3465) : warning C4101: 'mode_byte_obj2' : unreferenced local variableC:\Users\GJWood\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO "/LIBPATH:C:/Program Files (x86)/Graphviz2.38/lib/release/lib" /LIBPATH:c:\Users\GJWood\Anaconda\libs /LIBPATH:c:\Users\GJWood\Anaconda\PCbuild\amd64 cgraph.lib cdt.lib /EXPORT:init_graphviz build\temp.win-amd64-2.7\Release\pygraphviz/graphviz_wrap.obj /OUT:build\lib.win-amd64-2.7\pygraphviz\_graphviz.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\pygraphviz\_graphviz.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\pygraphviz\_graphviz.pyd.manifestgraphviz_wrap.obj : warning LNK4197: export 'init_graphviz' specified multiple times; using first specification Creating library build\temp.win-amd64-2.7\Release\pygraphviz\_graphviz.lib and object build\temp.win-amd64-2.7\Release\pygraphviz\_graphviz.expgraphviz_wrap.obj : error LNK2019: unresolved external symbol agsafeset referenced in function agsafeset_labelgraphviz_wrap.obj : error LNK2019: unresolved external symbol agstrdup_html referenced in function agsafeset_labelgraphviz_wrap.obj : error LNK2019: unresolved external symbol agattr referenced in function agattr_labelgraphviz_wrap.obj : error LNK2019: unresolved external symbol agopen referenced in function _wrap_agopengraphviz_wrap.obj : error LNK2019: unresolved external symbol agclose referenced in function _wrap_agclosegraphviz_wrap.obj : error LNK2019: unresolved external symbol agread referenced in function _wrap_agreadgraphviz_wrap.obj : error LNK2019: unresolved external symbol agwrite referenced in function _wrap_agwritegraphviz_wrap.obj : error LNK2019: unresolved external symbol agisundirected referenced in function _wrap_agisundirectedgraphviz_wrap.obj : error LNK2019: unresolved external symbol agisdirected referenced in function _wrap_agisdirectedgraphviz_wrap.obj : error LNK2019: unresolved external symbol agisstrict referenced in function _wrap_agisstrictgraphviz_wrap.obj : error LNK2019: unresolved external symbol agnode referenced in function _wrap_agnodegraphviz_wrap.obj : error LNK2019: unresolved external symbol agidnode referenced in function _wrap_agidnodegraphviz_wrap.obj : error LNK2019: unresolved external symbol agsubnode referenced in function _wrap_agsubnodegraphviz_wrap.obj : error LNK2019: unresolved external symbol agfstnode referenced in function _wrap_agfstnodegraphviz_wrap.obj : error LNK2019: unresolved external symbol agnxtnode referenced in function _wrap_agnxtnodegraphviz_wrap.obj : error LNK2019: unresolved external symbol aglstnode referenced in function _wrap_aglstnodegraphviz_wrap.obj : error LNK2019: unresolved external symbol agprvnode referenced in function _wrap_agprvnodegraphviz_wrap.obj : error LNK2019: unresolved external symbol agedge referenced in function _wrap_agedgegraphviz_wrap.obj : error LNK2019: unresolved external symbol agidedge referenced in function _wrap_agidedgegraphviz_wrap.obj : error LNK2019: unresolved external symbol agsubedge referenced in function _wrap_agsubedgegraphviz_wrap.obj : error LNK2019: unresolved external symbol agfstin referenced in function _wrap_agfstingraphviz_wrap.obj : error LNK2019: unresolved external symbol agnxtin referenced in function _wrap_agnxtingraphviz_wrap.obj : error LNK2019: unresolved external symbol agfstout referenced in function _wrap_agfstoutgraphviz_wrap.obj : error LNK2019: unresolved external symbol agnxtout referenced in function _wrap_agnxtoutgraphviz_wrap.obj : error LNK2019: unresolved external symbol agfstedge referenced in function _wrap_agfstedgegraphviz_wrap.obj : error LNK2019: unresolved external symbol agnxtedge referenced in function _wrap_agnxtedgegraphviz_wrap.obj : error LNK2019: unresolved external symbol agattrsym referenced in function _wrap_agattrsymgraphviz_wrap.obj : error LNK2019: unresolved external symbol agnxtattr referenced in function _wrap_agnxtattrgraphviz_wrap.obj : error LNK2019: unresolved external symbol agget referenced in function _wrap_aggetgraphviz_wrap.obj : error LNK2019: unresolved external symbol agxget referenced in function _wrap_agxgetgraphviz_wrap.obj : error LNK2019: unresolved external symbol agset referenced in function _wrap_agsetgraphviz_wrap.obj : error LNK2019: unresolved external symbol agxset referenced in function _wrap_agxsetgraphviz_wrap.obj : error LNK2019: unresolved external symbol agsubg referenced in function _wrap_agsubggraphviz_wrap.obj : error LNK2019: unresolved external symbol agfstsubg referenced in function _wrap_agfstsubggraphviz_wrap.obj : error LNK2019: unresolved external symbol agnxtsubg referenced in function _wrap_agnxtsubggraphviz_wrap.obj : error LNK2019: unresolved external symbol agparent referenced in function _wrap_agparentgraphviz_wrap.obj : error LNK2019: unresolved external symbol agroot referenced in function _wrap_agrootgraphviz_wrap.obj : error LNK2019: unresolved external symbol agdelsubg referenced in function _wrap_agdelsubggraphviz_wrap.obj : error LNK2019: unresolved external symbol agnnodes referenced in function _wrap_agnnodesgraphviz_wrap.obj : error LNK2019: unresolved external symbol agnedges referenced in function _wrap_agnedgesgraphviz_wrap.obj : error LNK2019: unresolved external symbol agdegree referenced in function _wrap_agdegreegraphviz_wrap.obj : error LNK2019: unresolved external symbol agraphof referenced in function _wrap_agraphofgraphviz_wrap.obj : error LNK2019: unresolved external symbol agnameof referenced in function _wrap_agnameofgraphviz_wrap.obj : error LNK2019: unresolved external symbol agdelnode referenced in function _wrap_agdelnodegraphviz_wrap.obj : error LNK2019: unresolved external symbol agdeledge referenced in function _wrap_agdeledgegraphviz_wrap.obj : error LNK2019: unresolved external symbol Agdirected referenced in function Swig_var_Agdirected_getgraphviz_wrap.obj : error LNK2019: unresolved external symbol Agstrictdirected referenced in function Swig_var_Agstrictdirected_getgraphviz_wrap.obj : error LNK2019: unresolved external symbol Agundirected referenced in function Swig_var_Agundirected_getgraphviz_wrap.obj : error LNK2019: unresolved external symbol Agstrictundirected referenced in function Swig_var_Agstrictundirected_getbuild\lib.win-amd64-2.7\pygraphviz\_graphviz.pyd : fatal error LNK1120: 49 unresolved externalserror: command 'C:\\Users\\GJWood\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\link.exe' failed with exit status 1120
At this time I think of, can be to http://www.lfd.uci.edu /~ Gohlke/pythonlibs/directly download the. whl file.
Download and install
pip install pygraphviz‑1.3.1‑cp27‑none‑win_amd64.whl
Success
However, this is not over.
When I try to run the following code:
import pygraphviz as pgvG=pgv.AGraph(strict=False,directed=True)G.add_node('a')G.add_node('b')G.add_edge('b','c')nodelist=['f','g','h']G.add_nodes_from(nodelist)#attributesG.graph_attr['label']="simple nodes and edge"G.node_attr['shape']='circle'G.edge_attr['color']='red's=G.to_string()G.write("first.dot")G.layout(prog='dot')G.draw('first.png')
It still reports an error
Traceback (most recent call last): File "D:\Program Files\Eclipse\plugins\org.python.pydev_3.3.3.201401272249\pysrc\pydevd.py", line 1738, in <module> debugger.run(setup['file'], None, None) File "D:\Program Files\Eclipse\plugins\org.python.pydev_3.3.3.201401272249\pysrc\pydevd.py", line 1355, in run pydev_imports.execfile(file, globals, locals) # execute the script File "D:\Users\SUUSER\workspace\ThreadGraph\parseText.py", line 17, in <module> G.layout(prog='dot') File "C:\Python27\lib\site-packages\pygraphviz\agraph.py", line 1305, in layout data=self._run_prog(prog,' '.join([args,"-T",fmt])) File "C:\Python27\lib\site-packages\pygraphviz\agraph.py", line 1251, in _run_prog runprog=r'"%s"'%self._get_prog(prog) File "C:\Python27\lib\site-packages\pygraphviz\agraph.py", line 1239, in _get_prog raise ValueError("Program %s not found in path."%prog)ValueError: Program dot not found in path.
The information found says "PyGraphviz doesn't work without Graphviz. Install that too." (http://stackoverflow.com/questions/13987353/python-valueerror-program-dot-not-found-in-path? Rq = 1)
But I have installed it. This is just to remember, is it necessary to set the environment variable or something: I added C: \ Program Files (x86) \ Graphviz2.38 \ bin to the PATH
Close pycharm, restart, run, OK, no error reported
Finally, release the download link.
Graphviz-2.38.msi link: http://pan.baidu.com/s/1nu4wcgp password: zazz
Pygraphviz unzip 1.3.1 unzip cp27 unzip none unzip win_amd64.whl link: http://pan.baidu.com/s/1c1nJyKg password: wra9