我在运行Python 3.7的Windows 10 X64上安装pygraphviz时遇到问题。我使用以下命令安装了graphviz:pip install graphviz,如下所示:Pip install pygraphviz fails: Failed building wheel for pygraphviz。我不知道需要做什么才能使pygraphviz运行。任何帮助,将不胜感激。预先感谢。
运行pip安装pygraphviz时,遇到以下错误:
Microsoft Windows [Version 10.0.18362.836]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\prash>pip install pygraphviz
Collecting pygraphviz
Using cached https://files.pythonhosted.org/packages/7e/b1/d6d849ddaf6f11036f9980d433f383d4c13d1ebcfc3cd09bc845bda7e433/pygraphviz-1.5.zip
Building wheels for collected packages: pygraphviz
Building wheel for pygraphviz (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\prash\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\prash\\AppData\\Local\\Temp\\pip-install-pa571k38\\pygraphviz\\setup.py'"'"'; __file__='"'"'C:\\Users\\prash\\AppData\\Local\\Temp\\pip-install-pa571k38\\pygraphviz\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\prash\AppData\Local\Temp\pip-wheel-zkrlosp9' --python-tag cp37
cwd: C:\Users\prash\AppData\Local\Temp\pip-install-pa571k38\pygraphviz\
Complete output (54 lines):
running bdist_wheel
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 -IC:\Users\prash\Anaconda3\include -IC:\Users\prash\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" /Tcpygraphviz/graphviz_wrap.c /Fobuild\temp.win-amd64-3.7\Release\pygraphviz/graphviz_wrap.obj
graphviz_wrap.c
c:\users\prash\anaconda3\include\pyconfig.h(203): fatal error C1083: Cannot open include file: 'basetsd.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
----------------------------------------
ERROR: Failed building wheel for pygraphviz
Running setup.py clean for pygraphviz
Failed to build pygraphviz
Installing collected packages: pygraphviz
Running setup.py install for pygraphviz ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\prash\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\prash\\AppData\\Local\\Temp\\pip-install-pa571k38\\pygraphviz\\setup.py'"'"'; __file__='"'"'C:\\Users\\prash\\AppData\\Local\\Temp\\pip-install-pa571k38\\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\prash\AppData\Local\Temp\pip-record-pvkn27t1\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\prash\AppData\Local\Temp\pip-install-pa571k38\pygraphviz\
Complete output (56 lines):
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 -IC:\Users\prash\Anaconda3\include -IC:\Users\prash\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" /Tcpygraphviz/graphviz_wrap.c /Fobuild\temp.win-amd64-3.7\Release\pygraphviz/graphviz_wrap.obj
graphviz_wrap.c
c:\users\prash\anaconda3\include\pyconfig.h(203): fatal error C1083: Cannot open include file: 'basetsd.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
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\prash\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\prash\\AppData\\Local\\Temp\\pip-install-pa571k38\\pygraphviz\\setup.py'"'"'; __file__='"'"'C:\\Users\\prash\\AppData\\Local\\Temp\\pip-install-pa571k38\\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\prash\AppData\Local\Temp\pip-record-pvkn27t1\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
似乎您缺少basetsd.h
。尝试下载并安装Windows 10 SDK。由于您已经拥有Visual Studio编译器,因此只需要安装Developer Tools> Windows Headers and Libraries,其中缺少basetsd.h
。