我正在浏览jupyter上的图形,并且由于NetworkX没有提供好的图表表示,因此我尝试使用GraphViz软件包,更具体地说是在那里找到的软件包:https://github.com/chebee7i/nxpd。
我首先导入了NXPD软件包,但是当我尝试使用draw()函数时,我遇到了此错误:
InvocationException:找不到GraphViz的可执行文件。
我首先认为这是因为我没有安装pygraphviz软件包,这是我尝试做的,但是我现在遇到了这个错误:
Collecting pygraphviz
Using cached pygraphviz-1.3.1.zip
Building wheels for collected packages: pygraphviz
Running setup.py bdist_wheel for pygraphviz: started
Running setup.py bdist_wheel for pygraphviz: finished with status 'error'
Complete output from command "D:Program Files (x86)Anaconda3python.exe" -u -c "import setuptools, tokenize;__file__='C:\Users\VPELL_~1\AppData\Local\Temp\pip-build-vs56t5f2\pygraphviz\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('rn', 'n'), __file__, 'exec'))" bdist_wheel -d C:UsersVPELL_~1AppDataLocalTemptmpqiovc8brpip-wheel- --python-tag cp35:
running bdist_wheel
running build
running build_py
creating build
creating buildlib.win-amd64-3.5
creating buildlib.win-amd64-3.5pygraphviz
copying pygraphvizagraph.py -> buildlib.win-amd64-3.5pygraphviz
copying pygraphvizgraphviz.py -> buildlib.win-amd64-3.5pygraphviz
copying pygraphvizrelease.py -> buildlib.win-amd64-3.5pygraphviz
copying pygraphvizversion.py -> buildlib.win-amd64-3.5pygraphviz
copying pygraphviz__init__.py -> buildlib.win-amd64-3.5pygraphviz
creating buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_attributes.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_attribute_defaults.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_clear.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_drawing.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_edge_attributes.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_graph.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_html.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_layout.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_node_attributes.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_readwrite.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_string.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_subgraph.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_unicode.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphviztests__init__.py -> buildlib.win-amd64-3.5pygraphviztests
running egg_info
writing dependency_links to pygraphviz.egg-infodependency_links.txt
writing top-level names to pygraphviz.egg-infotop_level.txt
writing pygraphviz.egg-infoPKG-INFO
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pygraphviz.egg-infoSOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '*~' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '.svn' found anywhere in distribution
no previously-included directories found matching 'docbuild'
writing manifest file 'pygraphviz.egg-infoSOURCES.txt'
copying pygraphvizgraphviz.i -> buildlib.win-amd64-3.5pygraphviz
copying pygraphvizgraphviz_wrap.c -> buildlib.win-amd64-3.5pygraphviz
running build_ext
building 'pygraphviz._graphviz' extension
creating buildtemp.win-amd64-3.5
creating buildtemp.win-amd64-3.5Release
creating buildtemp.win-amd64-3.5Releasepygraphviz
C:Program Files (x86)Microsoft Visual Studio 14.0VCBINx86_amd64cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-ID:Program Files (x86)Anaconda3include" "-ID:Program Files (x86)Anaconda3include" "-IC:Program Files (x86)Microsoft Visual Studio 14.0VCINCLUDE" "-IC:Program Files (x86)Windows Kits10include10.0.10240.0ucrt" "-IC:Program Files (x86)Windows Kits8.1includeshared" "-IC:Program Files (x86)Windows Kits8.1includeum" "-IC:Program Files (x86)Windows Kits8.1includewinrt" /Tcpygraphviz/graphviz_wrap.c /Fobuildtemp.win-amd64-3.5Releasepygraphviz/graphviz_wrap.obj
graphviz_wrap.c
pygraphviz/graphviz_wrap.c(2954): fatal error C1083: Cannot open include file: 'graphviz/cgraph.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 2
----------------------------------------
Running setup.py clean for pygraphviz
Failed to build pygraphviz
Installing collected packages: pygraphviz
Running setup.py install for pygraphviz: started
Running setup.py install for pygraphviz: finished with status 'error'
Complete output from command "D:Program Files (x86)Anaconda3python.exe" -u -c "import setuptools, tokenize;__file__='C:\Users\VPELL_~1\AppData\Local\Temp\pip-build-vs56t5f2\pygraphviz\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('rn', 'n'), __file__, 'exec'))" install --record C:UsersVPELL_~1AppDataLocalTemppip-fplxc9at-recordinstall-record.txt --single-version-externally-managed --compile:
running install
include_dirs=None
library_dirs=None
running build
running build_py
creating build
creating buildlib.win-amd64-3.5
creating buildlib.win-amd64-3.5pygraphviz
copying pygraphvizagraph.py -> buildlib.win-amd64-3.5pygraphviz
copying pygraphvizgraphviz.py -> buildlib.win-amd64-3.5pygraphviz
copying pygraphvizrelease.py -> buildlib.win-amd64-3.5pygraphviz
copying pygraphvizversion.py -> buildlib.win-amd64-3.5pygraphviz
copying pygraphviz__init__.py -> buildlib.win-amd64-3.5pygraphviz
creating buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_attributes.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_attribute_defaults.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_clear.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_drawing.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_edge_attributes.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_graph.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_html.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_layout.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_node_attributes.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_readwrite.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_string.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_subgraph.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphvizteststest_unicode.py -> buildlib.win-amd64-3.5pygraphviztests
copying pygraphviztests__init__.py -> buildlib.win-amd64-3.5pygraphviztests
running egg_info
writing dependency_links to pygraphviz.egg-infodependency_links.txt
writing pygraphviz.egg-infoPKG-INFO
writing top-level names to pygraphviz.egg-infotop_level.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pygraphviz.egg-infoSOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '*~' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '.svn' found anywhere in distribution
no previously-included directories found matching 'docbuild'
writing manifest file 'pygraphviz.egg-infoSOURCES.txt'
copying pygraphvizgraphviz.i -> buildlib.win-amd64-3.5pygraphviz
copying pygraphvizgraphviz_wrap.c -> buildlib.win-amd64-3.5pygraphviz
running build_ext
building 'pygraphviz._graphviz' extension
creating buildtemp.win-amd64-3.5
creating buildtemp.win-amd64-3.5Release
creating buildtemp.win-amd64-3.5Releasepygraphviz
C:Program Files (x86)Microsoft Visual Studio 14.0VCBINx86_amd64cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -INone "-ID:Program Files (x86)Anaconda3include" "-ID:Program Files (x86)Anaconda3include" "-IC:Program Files (x86)Microsoft Visual Studio 14.0VCINCLUDE" "-IC:Program Files (x86)Windows Kits10include10.0.10240.0ucrt" "-IC:Program Files (x86)Windows Kits8.1includeshared" "-IC:Program Files (x86)Windows Kits8.1includeum" "-IC:Program Files (x86)Windows Kits8.1includewinrt" /Tcpygraphviz/graphviz_wrap.c /Fobuildtemp.win-amd64-3.5Releasepygraphviz/graphviz_wrap.obj
graphviz_wrap.c
pygraphviz/graphviz_wrap.c(2954): fatal error C1083: Cannot open include file: 'graphviz/cgraph.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 2
----------------------------------------
Failed building wheel for pygraphviz
Command ""D:Program Files (x86)Anaconda3python.exe" -u -c "import setuptools, tokenize;__file__='C:\Users\VPELL_~1\AppData\Local\Temp\pip-build-vs56t5f2\pygraphviz\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('rn', 'n'), __file__, 'exec'))" install --record C:UsersVPELL_~1AppDataLocalTemppip-fplxc9at-recordinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:UsersVPELL_~1AppDataLocalTemppip-build-vs56t5f2pygraphviz
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
在stackoverflow上搜索后,我添加了以下目录:
D:Program Files (x86)Anaconda3Libsite-packagesgraphvizbin
D:Program Files (x86)Anaconda3Libsite-packagesgraphvizincludegraphviz
通往我的道路,但没有改变任何东西。
感谢您的帮助。
您是否在命令提示符中添加了路径:
PATH = %PATH%;<new path stuff>
或您使用系统属性中的环境变量添加了它?
我发现我需要使用系统属性将其添加,以使其宽。当仅使用命令提示符添加时,它仍然没有用。
尝试使用os.environ在jupyter笔记本本身中添加路径。
import os
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'