pygraphviz win7安装报错解决

贴一下错误提示:
Collecting pygraphviz
Using cached https://files.pythonhosted.org/packages/7e/b1/d6d849ddaf6f11036f9980d433f383d4c13d1ebcfc3cd09bc845bda7e433/pygraphviz-1.5.zip
Installing collected packages: pygraphviz
Running setup.py install for pygraphviz … error
Complete output from command E:\workspace\pycharm\py_data\venv\Scripts\python.exe -u -c “import setuptools, tokenize;file=‘C:\Users\3333\AppData\Local\Temp\pip-install-dn6gkuzu\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\3333\AppData\Local\Temp\pip-record-ctlb9vhn\install-rec
ord.txt --single-version-externally-managed --compile --install-headers E:\workspace\pycharm\py_data\venv\include\site\python3.7\pygraphviz:
running install
include_dirs=None
library_dirs=None
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\pygraphviz
copying pygraphviz\agraph.py -> build\lib.win-amd64-3.7\pygraphviz
copying pygraphviz\graphviz.py -> build\lib.win-amd64-3.7\pygraphviz
copying pygraphviz\release.py -> build\lib.win-amd64-3.7\pygraphviz
copying pygraphviz\version.py -> build\lib.win-amd64-3.7\pygraphviz
copying pygraphviz_init_.py -> build\lib.win-amd64-3.7\pygraphviz
creating build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_attributes.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_attribute_defaults.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_clear.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_drawing.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_edge_attributes.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_graph.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_html.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_layout.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_node_attributes.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_readwrite.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_setup.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_string.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_subgraph.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests\test_unicode.py -> build\lib.win-amd64-3.7\pygraphviz\tests
copying pygraphviz\tests_init_.py -> build\lib.win-amd64-3.7\pygraphviz\tests
running egg_info
writing pygraphviz.egg-info\PKG-INFO
writing dependency_links to pygraphviz.egg-info\dependency_links.txt
writing top-level names to pygraphviz.egg-info\top_level.txt
reading manifest file ‘pygraphviz.egg-info\SOURCES.txt’
reading manifest template ‘MANIFEST.in’
warning: no files found matching ‘.png’ under directory ‘doc’
warning: no files found matching '
.html’ under directory ‘doc’
warning: no files found matching ‘.txt’ under directory ‘doc’
warning: no files found matching '
.css’ under directory ‘doc’
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 ‘doc\build’
writing manifest file ‘pygraphviz.egg-info\SOURCES.txt’
copying pygraphviz\graphviz.i -> build\lib.win-amd64-3.7\pygraphviz
copying pygraphviz\graphviz_wrap.c -> build\lib.win-amd64-3.7\pygraphviz
running build_ext
building ‘pygraphviz._graphviz’ extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\pygraphviz
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IE:\workspace\pycharm\py_da
ta\venv\include “-ID:\Program Files\python3\include” “-ID:\Program Files\python3\include” “-IC:\Program Files (x86)\Microsoft Visual Studio 14.0
\VC\INCLUDE” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt” “-IC:\Program Files (x86)\Windows Kits\8.1\include\shared” “-I
C:\Program Files (x86)\Windows Kits\8.1\include\um” “-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt” /Tcpygraphviz/graphviz_wrap.c /Fob
uild\temp.win-amd64-3.7\Release\pygraphviz/graphviz_wrap.obj
graphviz_wrap.c
pygraphviz/graphviz_wrap.c(2987): 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

----------------------------------------

Command “E:\workspace\pycharm\py_data\venv\Scripts\python.exe -u -c “import setuptools, tokenize;file=‘C:\Users\3333\AppData\Local\
Temp\pip-install-dn6gkuzu\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\3333\AppData\Local\Temp\pip-record-ctlb9vhn\install-record.txt --single-version
-externally-managed --compile --install-headers E:\workspace\pycharm\py_data\venv\include\site\python3.7\pygraphviz” failed with error code 1 in
C:\Users\3333\AppData\Local\Temp\pip-install-dn6gkuzu\pygraphviz\


问题分析

pygraphviz是基于graphviz的实现,因此在pip install pygraphviz 或 python setup.py install 命令时,需要依赖graphviz的c++类库。因此可以手动下载安装。地址:https://graphviz.gitlab.io/_pages/Download/Download_windows.html
在windows系统下,就算是安装了graphviz也别指望一帆风顺,在安装完graphviz再编译(python setup.py install)时,主要会出现
1、类库找不到pygraphviz/graphviz_wrap.c(2987): fatal error C1083: Cannot open include file: 'graphviz/cgraph.h': No such file or directory
2、cbt.lib cannot open input file 'cdt.lib' 还是类库问题,graphviz中有这个类库,python没加载到
3、unresolved external symbol agwrite 32位和64位系统的问题,graphviz官方只有32位的
4、unresolved external symbol PyIOBase_Type python中c文件的问题,附件有大神修复的c文件

下满我就按照网上大神的博文,一步一步操作,大神的博文写的较多,想研究的请移步》》》https://www.cnblogs.com/xiaojieshisilang/p/9495295.html ,我只是简单记录步骤,不分析原因,哈哈

安装步骤

1、我是通过anaconda的方式安装的,基本跟python一致。如果您已经有python环境,并且可以运行pip也是可以的。
2、下载graphviz,免安装版解压即可。
3、下载pygraphviz源码包,。https://pypi.org/project/pygraphviz/#files 解压缩即可
4、修改pygraphviz中的setup.py文件,修改后为include_dirs=[], library_dirs=[r'D:\lib\release\lib\release\lib'],
5、附件中的\GraphViz_x64-master\graphviz-2.38_x64\lib内容放置到:
graphviz的的release的lib下面,而不是直接的lib下面C:\Program Files (x86)\Graphviz2.38\lib\release\lib
6、附件中pygraphviz/graphviz.i和pygraphviz/graphviz_wrap.c文件覆盖pygraphviz源码包中的文件
7、进入pygraphviz中,运行python setup.py install --include-path=D:\lib\release\include --library-path=D:\lib\release\lib 即可完成安装。
ps:安装成功后,也可能会运行报错,参考大神的解决即可,这个我没有尝试

附件(来源于大神,非本人)

链接:https://pan.baidu.com/s/18VKkVj_CupmvFwihdHwH8Q 密码:aqr7

你可能感兴趣的:(python)