纪念一下装了一天终于成功了的 pygraphviz
2015-12-05 15:37
393 查看
老师给了我们一个python文件让我们看懂,然后里面有一句
成功啦
然而这并没有结束
当我试着打了如下代码,并运行时:
它依旧报错
查到的资料说“PyGraphvizdoesn'tworkwithoutGraphviz.Installthattoo.”(http://stackoverflow.com/questions/13987353/python-valueerror-program-dot-not-found-in-path?rq=1)
可是我已经装了呀。这是才想起来,是不是还要设置环境变量什么的:我又把C:\ProgramFiles(x86)\Graphviz2.38\bin加到PATH里去
关了pycharm,重开,运行,OK,不报错了
最后的最后,放出相关下载链接
importpygraphvizaspgv 为了能让程序在自己的电脑上,跑起来,我像往常一样,用pipinstallpygraphviz来安装,然后,另人苦逼的是各种报错哇。 然后在github下载了包(https://github.com/pygraphviz),解压后用pythonsetup.pyinstall 报错,内容为fatalerror:graphviz/cgraph.h:Nosuchfile 然后在stackoverflow上找到的解决办法是 编辑setup.py文件中添加这些位置作为目录: [code]include_dirs='C:/ProgramFiles(x86)/Graphviz2.38/include' library_dirs='C:/ProgramFiles(x86)/Graphviz2.38/lib'
同时我在readme里面看到,这个需要和Graphviz软件一起使用,而我并没有下载,好滴吧,先到官网上下载了Graphviz-2.38
并且添加了目录 再次install 然后错误变得更多了:
$pythonsetup.pyinstall library_dirs=C:/ProgramFiles(x86)/Graphviz2.38/lib/release/lib include_dirs=C:/ProgramFiles(x86)/Graphviz2.38/include runninginstall runningbdist_egg runningegg_info writingpygraphviz.egg-info\PKG-INFO writingtop-levelnamestopygraphviz.egg-info\top_level.txt writingdependency_linkstopygraphviz.egg-info\dependency_links.txt readingmanifestfile'pygraphviz.egg-info\SOURCES.txt' readingmanifesttemplate'MANIFEST.in' warning:nopreviously-includedfilesmatching'*~'foundanywhereindistribution warning:nopreviously-includedfilesmatching'*.pyc'foundanywhereindistribution warning:nopreviously-includedfilesmatching'.svn'foundanywhereindistribution nopreviously-includeddirectoriesfoundmatching'doc\build' writingmanifestfile'pygraphviz.egg-info\SOURCES.txt' installinglibrarycodetobuild\bdist.win-amd64\egg runninginstall_lib runningbuild_py runningbuild_ext building'pygraphviz._graphviz'extension C:\Users\GJWood\AppData\Local\Programs\Common\Microsoft\VisualC++forPython\9.0\VC\Bin\amd64\cl.exe/c/nologo/Ox/MD /W3/GS-/DNDEBUG-DGVDLL"-IC:/ProgramFiles(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.obj graphviz_wrap.c pygraphviz/graphviz_wrap.c(3295):warningC4267:'=':conversionfrom'size_t'to'int',possiblelossofdata pygraphviz/graphviz_wrap.c(3313):warningC4267:'=':conversionfrom'size_t'to'int',possiblelossofdata pygraphviz/graphviz_wrap.c(3321):warningC4047:'return':'int'differsinlevelsofindirectionfrom'Agsym_t*' pygraphviz/graphviz_wrap.c(3407):warningC4101:'mode_byte_obj1':unreferencedlocalvariable pygraphviz/graphviz_wrap.c(3406):warningC4101:'mode_obj1':unreferencedlocalvariable pygraphviz/graphviz_wrap.c(3408):warningC4101:'mode1':unreferencedlocalvariable pygraphviz/graphviz_wrap.c(3405):warningC4101:'fd1':unreferencedlocalvariable pygraphviz/graphviz_wrap.c(3466):warningC4101:'mode2':unreferencedlocalvariable pygraphviz/graphviz_wrap.c(3464):warningC4101:'mode_obj2':unreferencedlocalvariable pygraphviz/graphviz_wrap.c(3463):warningC4101:'fd2':unreferencedlocalvariable pygraphviz/graphviz_wrap.c(3465):warningC4101:'mode_byte_obj2':unreferencedlocalvariable C:\Users\GJWood\AppData\Local\Programs\Common\Microsoft\VisualC++forPython\9.0\VC\Bin\amd64\link.exe/DLL/nologo/IN CREMENTAL:NO"/LIBPATH:C:/ProgramFiles(x86)/Graphviz2.38/lib/release/lib"/LIBPATH:c:\Users\GJWood\Anaconda\libs/LIBP ATH:c:\Users\GJWood\Anaconda\PCbuild\amd64cgraph.libcdt.lib/EXPORT:init_graphvizbuild\temp.win-amd64-2.7\Release\pyg raphviz/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.manifest graphviz_wrap.obj:warningLNK4197:export'init_graphviz'specifiedmultipletimes;usingfirstspecification Creatinglibrarybuild\temp.win-amd64-2.7\Release\pygraphviz\_graphviz.libandobjectbuild\temp.win-amd64-2.7\Releas e\pygraphviz\_graphviz.exp graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagsafesetreferencedinfunctionagsafeset_label graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagstrdup_htmlreferencedinfunctionagsafeset_label graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagattrreferencedinfunctionagattr_label graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagopenreferencedinfunction_wrap_agopen graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagclosereferencedinfunction_wrap_agclose graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagreadreferencedinfunction_wrap_agread graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagwritereferencedinfunction_wrap_agwrite graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagisundirectedreferencedinfunction_wrap_agisundirected graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagisdirectedreferencedinfunction_wrap_agisdirected graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagisstrictreferencedinfunction_wrap_agisstrict graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagnodereferencedinfunction_wrap_agnode graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagidnodereferencedinfunction_wrap_agidnode graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagsubnodereferencedinfunction_wrap_agsubnode graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagfstnodereferencedinfunction_wrap_agfstnode graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagnxtnodereferencedinfunction_wrap_agnxtnode graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolaglstnodereferencedinfunction_wrap_aglstnode graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagprvnodereferencedinfunction_wrap_agprvnode graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagedgereferencedinfunction_wrap_agedge graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagidedgereferencedinfunction_wrap_agidedge graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagsubedgereferencedinfunction_wrap_agsubedge graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagfstinreferencedinfunction_wrap_agfstin graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagnxtinreferencedinfunction_wrap_agnxtin graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagfstoutreferencedinfunction_wrap_agfstout graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagnxtoutreferencedinfunction_wrap_agnxtout graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagfstedgereferencedinfunction_wrap_agfstedge graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagnxtedgereferencedinfunction_wrap_agnxtedge graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagattrsymreferencedinfunction_wrap_agattrsym graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagnxtattrreferencedinfunction_wrap_agnxtattr graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolaggetreferencedinfunction_wrap_agget graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagxgetreferencedinfunction_wrap_agxget graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagsetreferencedinfunction_wrap_agset graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagxsetreferencedinfunction_wrap_agxset graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagsubgreferencedinfunction_wrap_agsubg graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagfstsubgreferencedinfunction_wrap_agfstsubg graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagnxtsubgreferencedinfunction_wrap_agnxtsubg graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagparentreferencedinfunction_wrap_agparent graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagrootreferencedinfunction_wrap_agroot graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagdelsubgreferencedinfunction_wrap_agdelsubg graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagnnodesreferencedinfunction_wrap_agnnodes graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagnedgesreferencedinfunction_wrap_agnedges graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagdegreereferencedinfunction_wrap_agdegree graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagraphofreferencedinfunction_wrap_agraphof graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagnameofreferencedinfunction_wrap_agnameof graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagdelnodereferencedinfunction_wrap_agdelnode graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolagdeledgereferencedinfunction_wrap_agdeledge graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolAgdirectedreferencedinfunctionSwig_var_Agdirected_get graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolAgstrictdirectedreferencedinfunctionSwig_var_Agstrictd irected_get graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolAgundirectedreferencedinfunctionSwig_var_Agundirected_ get graphviz_wrap.obj:errorLNK2019:unresolvedexternalsymbolAgstrictundirectedreferencedinfunctionSwig_var_Agstric tundirected_get build\lib.win-amd64-2.7\pygraphviz\_graphviz.pyd:fatalerrorLNK1120:49unresolvedexternals error:command'C:\\Users\\GJWood\\AppData\\Local\\Programs\\Common\\Microsoft\\VisualC++forPython\\9.0\\VC\\Bin\\amd 64\\link.exe'failedwithexitstatus1120
这时候我才想起,可以到http://www.lfd.uci.edu/~gohlke/pythonlibs/直接下载.whl文件哇。 下载并安装
pipinstallpygraphviz‑1.3.1‑cp27‑none‑win_amd64.whl
成功啦
然而这并没有结束
当我试着打了如下代码,并运行时:
importpygraphvizaspgv
G=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)
#attributes
G.graph_attr['label']="simplenodesandedge"
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')
它依旧报错
Traceback(mostrecentcalllast):
File"D:\ProgramFiles\Eclipse\plugins\org.python.pydev_3.3.3.201401272249\pysrc\pydevd.py",line1738,in<module>
debugger.run(setup['file'],None,None)
File"D:\ProgramFiles\Eclipse\plugins\org.python.pydev_3.3.3.201401272249\pysrc\pydevd.py",line1355,inrun
pydev_imports.execfile(file,globals,locals)#executethescript
File"D:\Users\SUUSER\workspace\ThreadGraph\parseText.py",line17,in<module>
G.layout(prog='dot')
File"C:\Python27\lib\site-packages\pygraphviz\agraph.py",line1305,inlayout
data=self._run_prog(prog,''.join([args,"-T",fmt]))
File"C:\Python27\lib\site-packages\pygraphviz\agraph.py",line1251,in_run_prog
runprog=r'"%s"'%self._get_prog(prog)
File"C:\Python27\lib\site-packages\pygraphviz\agraph.py",line1239,in_get_prog
raiseValueError("Program%snotfoundinpath."%prog)
ValueError:Programdotnotfoundinpath.
查到的资料说“PyGraphvizdoesn'tworkwithoutGraphviz.Installthattoo.”(http://stackoverflow.com/questions/13987353/python-valueerror-program-dot-not-found-in-path?rq=1)
可是我已经装了呀。这是才想起来,是不是还要设置环境变量什么的:我又把C:\ProgramFiles(x86)\Graphviz2.38\bin加到PATH里去
关了pycharm,重开,运行,OK,不报错了
最后的最后,放出相关下载链接
graphviz-2.38.msi链接:http://pan.baidu.com/s/1nu4wcgp密码:zazz
pygraphviz‑1.3.1‑cp27‑none‑win_amd64.whl链接:http://pan.baidu.com/s/1c1nJyKg密码:wra9
相关文章推荐
- (六十八)组合运算符
- iOS开发常用第三方
- cocos游戏开发-vector的介绍
- Maven系列--"maven-compiler-plugin"的使用、Maven之Surefire插件
- Range Sum Query - Immutable
- 摇一摇功能
- mysql之sql优化
- _beginthread http://www.cnblogs.com/whiteyun/archive/2011/06/02/2067742.html
- 常见OJ提交结果对照表
- 实现TextView自动左右滚动文本
- iOS NSDictionary、NSData、JSON数据类型相互转换
- Ubuntu安装SSTP
- (六十七)前缀、后缀运算符号在其他地方的使用
- 剑指offer系列之十:二进制中1的个数
- 实际开发注意的问题
- AngularJS表单验证,手动验证或自动验证
- Unity给力插件之ShaderForge(二)
- Ubuntu下基于Nginx实现Tomcat集群负载均衡
- Dropout & Maxout
- OC-9.内存管理