Python 如何在 Windows 10 64 位上安装 pygraphviz

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40809758/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 00:01:54  来源:igfitidea点击:

howto install pygraphviz on windows 10 64bit

python64-bitwindows-10pygraphviz

提问by Hynek Los kamute

Has anyone succeeded in installing pygraphviz on windows 10 64bit? I tried anaconda with python 3.5 64bit & 32bit with no success.

有没有人成功地在 Windows 10 64 位上安装 pygraphviz?我在 python 3.5 64bit & 32bit 上尝试了 anaconda,但没有成功。

Here is the error I am getting with python 3.5 32bit on win10 64bit

这是我在 win10 64bit 上使用 python 3.5 32bit 遇到的错误

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\include.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits.1\include\shared" "-IC:\Program Files (x86)\Windows Kits.1\include\um" "-IC:\Program Files (x86)\Windows Kits.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\lib.0.10240.0\ucrt\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits.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?

我认为这与graphviz以32位链接的事实有关?

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 ...

注意 - 我尝试了所有可以在互联网(anaconda,internet)上找到的 pygraphviz 二进制文件,但在 win10 64bit 上没有任何工作......如果你有任何工作(我的意思是你真的测试过它),我也会很高兴......

采纳答案by MiniMe

Start reading from here https://github.com/pygraphviz/pygraphviz/issues/58

从这里开始阅读 https://github.com/pygraphviz/pygraphviz/issues/58

At the bottom of that page there is a link to a x64 zip file in Github (like this) Unpack that create a the coresponding Program Files folder for your x64 file and put them there

在该页面的底部,有一个指向 Github 中 x64 zip 文件的链接(像这样)解压缩,为您的 x64 文件创建一个相应的 Program Files 文件夹并将它们放在那里

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

回答by lubstep

I've created a build of PyGraphviz 1.5 on my Anaconda channelfor Windows 64 bit running Python 3.6 or Python 3.7. If you're running Anaconda, you can install with:

我已经在我的Anaconda 频道上为运行 Python 3.6 或 Python 3.7 的 Windows 64 位创建了一个 PyGraphviz 1.5 版本。如果您正在运行Anaconda,您可以安装:

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).

这也将安装 Graphviz 2.41 作为依赖项(不要单独安装它,它可能会冲突并且并非所有版本都兼容 64 位)。

I don't currently have a version for Python 3.5 or 32-bit versions of Windows, but I hope the above helps.

我目前没有适用于 Python 3.5 或 32 位版本的 Windows 的版本,但我希望以上内容有所帮助。

回答by r3robertson

The accepted answer didn't work for me running Python 2.7 (Anaconda) on Windows 10. The file path that @MiniMe suggested for --global-optiondidn't even exist in the git repo that he or she pointed to.

接受的答案对我在 Windows 10 上运行 Python 2.7 (Anaconda) 不起作用。@MiniMe 建议的文件路径--global-option甚至不存在于他或她指向的 git 存储库中。

What did work for me was following instructions provided by the (currently) bottom answer to: Installing pygraphviz on windows

对我有用的是遵循(当前)底部答案提供的说明:在 Windows 上安装 pygraphviz

Steps:
1. Download graphviz-2.38.msi from https://graphviz.gitlab.io/_pages/Download/Download_windows.htmland 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

步骤:
1. 从https://graphviz.gitlab.io/_pages/Download/Download_windows.html下载 graphviz-2.38.msi并安装
2. 下载 2.7 o?r? ?3?.?4? 您需要从http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygraphviz
下载wheel 文件 3. 导航到您将wheel 文件下载到的目录
4. 运行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 PATHbut I didn't need to. Good luck!

笔记??那??你??可能??有??到??跑?? ?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?? ?如果??你是??试??到??得到??它??到??工作??和??Python??3?.?4?.? ?一世??d?i?d?n?'?t? ?测试??那??尽管?。?此外,我引用的 SO 答案还提到需要将 graphviz 添加到您的PATH但我不需要。祝你好运!

Update: The python3 wheel vanished. If you're running python3, this answerworked 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

更新:python3 轮消失了。如果你正在运行 python3,这个答案对我有用。按照上面的步骤 1 操作,然后在 WSL bash 中运行:
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.

那个答案说要使用sudo pip install pygraphviz,但是由于某种原因,这给了我一个可怕的 pip 导入错误。删除 sudo 使它在我的情况下起作用。

回答by Kardi Teknomo

If all the solutions above failed, you can still clone directly from the pygraphviz repository

如果以上所有解决方案都失败了,您仍然可以直接从pygraphviz存储库中进行克隆

  1. Visit: https://github.com/pygraphviz/pygraphviz.git
  2. Download/Clone it
  3. put the folder into C:\Users\\AppData\Local\Programs\Python\Python37-32\Lib\site-packages
  4. Change directory to “pygraphviz”
  5. Run “python setup.py install” to build and install
  6. (optional) Run “python setup_egg.py nosetests” to execute the tests
  1. 访问:https: //github.com/pygraphviz/pygraphviz.git
  2. 下载/克隆它
  3. 将文件夹放入 C:\Users\\AppData\Local\Programs\Python\Python37-32\Lib\site-packages
  4. 将目录更改为“pygraphviz”
  5. 运行“python setup.py install”来构建和安装
  6. (可选)运行“python setup_egg.py nosetests”来执行测试

Source: http://pygraphviz.github.io/documentation/pygraphviz-1.3.1/install.html

来源:http: //pygraphviz.github.io/documentation/pygraphviz-1.3.1/install.html