windows 下安装python 的pygraphviz包方法

最开始,我通过pip install pygraphviz

出现以下问题:

Collecting pygraphviz
  Using cached pygraphviz-1.3.1.tar.gz
Building wheels for collected packages: pygraphviz
  Running setup.py bdist_wheel for pygraphviz
  Complete output from command C:\Python27\python.exe -c "import setuptools;__fi
le__='c:\\users\\luofuli\\appdata\\local\\temp\\7\\pip-build-vbneip\\pygraphviz\
\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, '
exec'))" bdist_wheel -d c:\users\luofuli\appdata\local\temp\7\tmp5xiixqpip-wheel
-:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-2.7
  creating build\lib.win-amd64-2.7\pygraphviz
  copying pygraphviz\agraph.py -> build\lib.win-amd64-2.7\pygraphviz
  copying pygraphviz\graphviz.py -> build\lib.win-amd64-2.7\pygraphviz
  copying pygraphviz\release.py -> build\lib.win-amd64-2.7\pygraphviz
  copying pygraphviz\version.py -> build\lib.win-amd64-2.7\pygraphviz
  copying pygraphviz\__init__.py -> build\lib.win-amd64-2.7\pygraphviz
  creating build\lib.win-amd64-2.7\pygraphviz\tests
  copying pygraphviz\tests\test.py -> build\lib.win-amd64-2.7\pygraphviz\tests
  copying pygraphviz\tests\test_attributes.py -> build\lib.win-amd64-2.7\pygraph
viz\tests
  copying pygraphviz\tests\test_attribute_defaults.py -> build\lib.win-amd64-2.7
\pygraphviz\tests
  copying pygraphviz\tests\test_clear.py -> build\lib.win-amd64-2.7\pygraphviz\t
ests
  copying pygraphviz\tests\test_drawing.py -> build\lib.win-amd64-2.7\pygraphviz
\tests
  copying pygraphviz\tests\test_edge_attributes.py -> build\lib.win-amd64-2.7\py
graphviz\tests
  copying pygraphviz\tests\test_graph.py -> build\lib.win-amd64-2.7\pygraphviz\t
ests
  copying pygraphviz\tests\test_html.py -> build\lib.win-amd64-2.7\pygraphviz\te
sts
  copying pygraphviz\tests\test_layout.py -> build\lib.win-amd64-2.7\pygraphviz\
tests
  copying pygraphviz\tests\test_node_attributes.py -> build\lib.win-amd64-2.7\py
graphviz\tests
  copying pygraphviz\tests\test_readwrite.py -> build\lib.win-amd64-2.7\pygraphv
iz\tests
  copying pygraphviz\tests\test_string.py -> build\lib.win-amd64-2.7\pygraphviz\
tests
  copying pygraphviz\tests\test_subgraph.py -> build\lib.win-amd64-2.7\pygraphvi
z\tests
  copying pygraphviz\tests\test_unicode.py -> build\lib.win-amd64-2.7\pygraphviz
\tests
  copying pygraphviz\tests\__init__.py -> build\lib.win-amd64-2.7\pygraphviz\tes
ts
  running egg_info
  writing pygraphviz.egg-info\PKG-INFO
  writing top-level names to pygraphviz.egg-info\top_level.txt
  writing dependency_links to pygraphviz.egg-info\dependency_links.txt
  warning: manifest_maker: standard file '-c' not found


  reading manifest file 'pygraphviz.egg-info\SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no previously-included files matching '*~' found anywhere in distribu
tion
  warning: no previously-included files matching '*.pyc' found anywhere in distr
ibution
  warning: no previously-included files matching '.svn' found anywhere in distri
bution
  no previously-included directories found matching 'doc\build'
  writing manifest file 'pygraphviz.egg-info\SOURCES.txt'
  copying pygraphviz\graphviz.i -> build\lib.win-amd64-2.7\pygraphviz
  copying pygraphviz\graphviz_wrap.c -> build\lib.win-amd64-2.7\pygraphviz
  running build_ext
  building 'pygraphviz._graphviz' extension
  creating build\temp.win-amd64-2.7
  creating build\temp.win-amd64-2.7\Release
  creating build\temp.win-amd64-2.7\Release\pygraphviz
  C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\cl.exe /c /no
logo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tcpygraph
viz/graphviz_wrap.c /Fobuild\temp.win-amd64-2.7\Release\pygraphviz/graphviz_wrap
.obj
  graphviz_wrap.c
  pygraphviz/graphviz_wrap.c(2954) : fatal error C1083: 无法打开包括文件:“graph
viz/cgraph.h”: No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN
\\amd64\\cl.exe' failed with exit status 2


  ----------------------------------------
  Failed building wheel for pygraphviz
Failed to build pygraphviz
Installing collected packages: pygraphviz
  Running setup.py install for pygraphviz
    Complete output from command C:\Python27\python.exe -c "import setuptools, t
okenize;__file__='c:\\users\\luofuli\\appdata\\local\\temp\\7\\pip-build-vbneip\
\pygraphviz\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).re
ad().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\luoful
i\appdata\local\temp\7\pip-qf6tkd-record\install-record.txt --single-version-ext
ernally-managed --compile:
    running install
    include_dirs=None
    library_dirs=None
    running build
    running build_py
    running egg_info
    writing pygraphviz.egg-info\PKG-INFO
    writing top-level names to pygraphviz.egg-info\top_level.txt
    writing dependency_links to pygraphviz.egg-info\dependency_links.txt
    warning: manifest_maker: standard file '-c' not found


    reading manifest file 'pygraphviz.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no previously-included files matching '*~' found anywhere in distri
bution
    warning: no previously-included files matching '*.pyc' found anywhere in dis
tribution
    warning: no previously-included files matching '.svn' found anywhere in dist
ribution
    no previously-included directories found matching 'doc\build'
    writing manifest file 'pygraphviz.egg-info\SOURCES.txt'
    running build_ext
    building 'pygraphviz._graphviz' extension
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\cl.exe /c /
nologo /Ox /MD /W3 /GS- /DNDEBUG -INone -IC:\Python27\include -IC:\Python27\PC /
Tcpygraphviz/graphviz_wrap.c /Fobuild\temp.win-amd64-2.7\Release\pygraphviz/grap
hviz_wrap.obj
    graphviz_wrap.c
    pygraphviz/graphviz_wrap.c(2954) : fatal error C1083: 无法打开包括文件:“gra
phviz/cgraph.h”: No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\B
IN\\amd64\\cl.exe' failed with exit status 2


    ----------------------------------------
Command "C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\us
ers\\luofuli\\appdata\\local\\temp\\7\\pip-build-vbneip\\pygraphviz\\setup.py';e
xec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n
'), __file__, 'exec'))" install --record c:\users\luofuli\appdata\local\temp\7\p
ip-qf6tkd-record\install-record.txt --single-version-externally-managed --compil
e" failed with error code 1 in c:\users\luofuli\appdata\local\temp\7\pip-build-v
bneip\pygraphviz


然后我又尝试easy_install pygraphviz

又出现以下问题:

Searching for pygraphviz
Reading https://pypi.python.org/simple/pygraphviz/
Best match: pygraphviz 1.3.1
Downloading https://pypi.python.org/packages/source/p/pygraphviz/pygraphviz-1.3.
1.zip#md5=b2a5b69fe8ff969949d4b9bb9dd2974d
Processing pygraphviz-1.3.1.zip
Writing c:\users\luofuli\appdata\local\temp\7\easy_install-qxyhf0\pygraphviz-1.3
.1\setup.cfg
Running pygraphviz-1.3.1\setup.py -q bdist_egg --dist-dir c:\users\luofuli\appda
ta\local\temp\7\easy_install-qxyhf0\pygraphviz-1.3.1\egg-dist-tmp-bab8w8
warning: no previously-included files matching '*~' found anywhere in distributi
on
warning: no previously-included files matching '*.pyc' found anywhere in distrib
ution
warning: no previously-included files matching '.svn' found anywhere in distribu
tion
no previously-included directories found matching 'doc\build'
graphviz_wrap.c
pygraphviz/graphviz_wrap.c(2954) : fatal error C1083: 无法打开包括文件:“graphvi
z/cgraph.h”: No such file or directory
error: Setup script exited with error: command 'C:\\Program Files (x86)\\Microso
ft Visual Studio 10.0\\VC\\BIN\\amd64\\cl.exe' failed with exit status 2


最后请教师兄,原来是pygraphviz没有windows版本的还是什么,总之不能通过这两种方法安装

于是采用了下载pygraphviz的.whl安装,

下载地址:http://www.lfd.uci.edu/~gohlke/pythonlibs/

ctrl+F查找pygraphviz,找到对应的版本,比如我是python2.7,64位操作系统,就下载pygraphviz-1.3.1-cp27-none-win_amd64.whl

最后打开cmd,先检测一下有没有安装wheel 通过pip install wheel,没有安装的会此时安装上,然后再pip install 包名字.whl即在我的电脑上:pip install pygraphviz-1.3.1-cp27-none-win_amd64.whl

出现如下:

Processing e:\sentence-compression-master\pygraphviz-1.3.1-cp27-none-win_amd64.whl
Installing collected packages: pygraphviz
Successfully installed pygraphviz-1.3.1


注意:安装pygraphviz之前貌似需要安装graphviz  直接通过pip install 就可以安装啦

安装成功啦!!!!

总结:如何安装.xml文件

1、下载.whl包
2、先pip install wheel,之后pip install 包名字.whl 即可安装某模块包
3、到哪找.whl文件?
http://www.lfd.uci.edu/~gohlke/pythonlibs/






你可能感兴趣的:(python学习)