问题
Has anyone succeeded in installing pygraphviz on windows 10 64bit? I tried anaconda with python 3.5 64bit & 32bit with no success.
Here is the error I am getting with python 3.5 32bit on win10 64bit
python -m pip install pygraphviz --install-option="--include-path=C:\Program Files (x86)\Graphviz2.38\include" --install-option="--library-path=C:\Program Files (x86)\Graphviz2.38\lib"
Error:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-IC:\Program Files (x86)\Graphviz2.38\include" -IC:\Users\tra20\Anaconda3\include -IC:\Users\tra20\Anaconda3\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" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcpygraphviz/graphviz_wrap.c /Fobuild\temp.win32-3.5\Release\pygraphviz/graphviz_wrap.obj
graphviz_wrap.c
pygraphviz/graphviz_wrap.c(3321): warning C4047: 'return': 'int' differs in levels of indirection from 'Agsym_t *'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:C:\Program Files (x86)\Graphviz2.38\lib" /LIBPATH:C:\Users\tra20\Anaconda3\libs /LIBPATH:C:\Users\tra20\Anaconda3\PCbuild\win32 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86" cgraph.lib cdt.lib /EXPORT:PyInit__graphviz build\temp.win32-3.5\Release\pygraphviz/graphviz_wrap.obj /OUT:build\lib.win32-3.5\pygraphviz\_graphviz.cp35-win32.pyd /IMPLIB:build\temp.win32-3.5\Release\pygraphviz\_graphviz.cp35-win32.lib
LINK : fatal error LNK1181: cannot open input file 'cgraph.lib'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\link.exe' failed with exit status 1181
I assume it has something to do with the fact graphviz is linked in 32bit?
Note - I tried all binary for pygraphviz i could found on internet(anaconda,internet), and none work on win10 64bit... if you have any working (i mean you realy tested it ) i would be also happy ...
回答1:
Start reading from here https://github.com/pygraphviz/pygraphviz/issues/58
At the bottom of that page there is a link to a x64 zip file in Github Unpack that create a the coresponding Program Files folder for your x64 file and put them there
Then install using this
pip install --global-option=build_ext --global-option="-IC:\Program Files\Graphviz2.38\include" --global-option="-LC:\Program Files\Graphviz2.38\lib\release\lib" pygraphviz
回答2:
I've created a build of PyGraphviz 1.5 on my Anaconda channel for Windows 64 bit running Python 3.6 or Python 3.7. If you're running Anaconda, you can install with:
conda install -c alubbock pygraphviz
This will also install Graphviz 2.41 as a dependency (don't install it separately, it might conflict and not all versions are 64-bit compatible).
I don't currently have a version for Python 3.5 or 32-bit versions of Windows, but I hope the above helps.
回答3:
The accepted answer didn't work for me running Python 2.7 (Anaconda) on Windows 10. The file path that @MiniMe suggested for --global-option
didn't even exist in the git repo that he or she pointed to.
What did work for me was following instructions provided by the (currently) bottom answer to: Installing pygraphviz on windows
Steps:
1. Download graphviz-2.38.msi from https://graphviz.gitlab.io/_pages/Download/Download_windows.html and install
2. Download the 2.7 o̶r̶ ̶3̶.̶4̶ wheel file you need from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygraphviz
3. Navigate to the directory that you downloaded the wheel file to
4. Run pip install pygraphviz-1.3.1-cp27-none-win_amd64.whl
5. Rejoice
N̶o̶t̶e̶ ̶t̶h̶a̶t̶ ̶y̶o̶u̶ ̶m̶i̶g̶h̶t̶ ̶h̶a̶v̶e̶ ̶t̶o̶ ̶r̶u̶n̶ ̶̶p̶i̶p̶ ̶i̶n̶s̶t̶a̶l̶l̶ ̶p̶y̶g̶r̶a̶p̶h̶v̶i̶z̶-̶1̶.̶3̶.̶1̶-̶c̶p̶3̶4̶-̶n̶o̶n̶e̶-̶w̶i̶n̶_̶a̶m̶d̶6̶4̶.̶w̶h̶l̶
̶ ̶i̶f̶ ̶y̶o̶u̶'̶r̶e̶ ̶t̶r̶y̶i̶n̶g̶ ̶t̶o̶ ̶g̶e̶t̶ ̶i̶t̶ ̶t̶o̶ ̶w̶o̶r̶k̶ ̶w̶i̶t̶h̶ ̶P̶y̶t̶h̶o̶n̶ ̶3̶.̶4̶.̶ ̶I̶ ̶d̶i̶d̶n̶'̶t̶ ̶t̶e̶s̶t̶ ̶t̶h̶a̶t̶ ̶t̶h̶o̶u̶g̶h̶.̶ Also, the SO answer I referenced also mentioned needing to add graphviz to your PATH
but I didn't need to. Good luck!
Update: The python3 wheel vanished. If you're running python3, this answer worked for me. Follow step 1 above and then in WSL bash run:
1. sudo apt-get install python-dev graphviz libgraphviz-dev pkg-config
2. pip install pygraphviz
That answers says to use sudo pip install pygraphviz
, but that gave me a dreaded pip import error for some reason. Dropping the sudo made it work in my case.
回答4:
If all the solutions above failed, you can still clone directly from the pygraphviz repository
- Visit: https://github.com/pygraphviz/pygraphviz.git
- Download/Clone it
- put the folder into C:\Users\\AppData\Local\Programs\Python\Python37-32\Lib\site-packages
- Change directory to “pygraphviz”
- Run “python setup.py install” to build and install
- (optional) Run “python setup_egg.py nosetests” to execute the tests
Source: http://pygraphviz.github.io/documentation/pygraphviz-1.3.1/install.html
来源:https://stackoverflow.com/questions/40809758/howto-install-pygraphviz-on-windows-10-64bit