howto install pygraphviz on windows 10 64bit
Asked Answered
H

10

27

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

Haletky answered 25/11, 2016 at 17:9 Comment(2)
[SO]: Installing pygraphviz on Windows 10 64-bit, Python 3.6 (@CristiFati's answer).Progeny
its solved here for windows 10Exonerate
F
8

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 (like this) Unpack that. Create a 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\" pygraphviz
Farrica answered 6/2, 2017 at 1:10 Comment(4)
Here's the link at the bottom of that issues page: github.com/mahkoCosmo/GraphViz_x64. What's strange is that the repo hasn't been updated in 8 months but the release directory you're pointing towards in \Graphviz2.38\lib doesn't exist.Fork
In my case (Win 10, Python 3.6), additionalIy, had to apply a patch described here github.com/pygraphviz/pygraphviz/issues/…Busybody
This throws 'graphviz/cgraph.h' : No such file or directory.Coterminous
This works for me, but it does not work if I try to specify these options in the requirements.txt file and then read the requirements.txt file inside the setup.py file to specify the install_requires. I get an parse error at --global-option.Fogbow
G
46

I've created a build of PyGraphviz 1.5 on my Anaconda channel for Windows 64 bit running Python 3.6 through 3.9. 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.

Gable answered 16/3, 2019 at 23:38 Comment(8)
saved me a lot of time. Thanks :)Ewart
This is slightly wrong, and does not work for me. I used conda install -c alubbock graphviz pygraphvizJd
@Julio I've just added a Python 3.8 build. Thanks for the reminder!Gable
this worked for me on windows 10. do dot -c after installationDemarcate
It didn't include neato. How do I get that to install with graphviz?Fairleigh
Unfortunately lack of neato is a known issue in the graphviz Windows release. Hopefully they'll resolve that soon.Gable
@Gable You, my man, are an angel. I am so grateful!Toolmaker
Worked like a charm on Python 3.8! Super great time saver.Hexangular
F
12

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.

Fork answered 16/5, 2017 at 18:44 Comment(11)
No quite sure why this got a zero score, but it worked for me as well.Anett
THe answer I provided was for Python 3.X this is the answer for 2.7Farrica
If you're trying to use pygraphviz on windows 10 bash instead, this answer worked for me (#40528548). Basically, just run: sudo apt-get install python-dev graphviz libgraphviz-dev pkg-config then sudo pip install pygraphvizFork
@r3robertson. where is the python 3.x file? i only see cp27 32 and 64 bit versions.Collogue
@Collogue I couldn't find the 3.x wheel on that site anymore either. I updated my answer with what worked for me on 3.6. Hopefully that helps.Fork
@r3robertson. Thanks. Hopefully someone can find it... i posted a bounty here #45094311. I even updated to visual studio 14 and it still doesn't install.Collogue
@Collogue Did you try using that other answer? I don't think I ever got it to work with Anaconda btw, I made a virtual environment via WSL, installed pygraphviz on that, and ran a jupyter notebook through that virtual environment.Fork
Your python3 link isn't even relevant to windowsAgbogla
This comment gave me the way to install (python v3.8, Win10x64): 1. install graphviz.gitlab.io/_pages/Download/Download_windows.html 2. add to path C:\Program Files (x86)\Graphviz2.38\bin 3. download github.com/CristiFati/Prebuilt-Binaries/blob/master/PyGraphviz/… 4. run pip install pygraphviz-1.5-cp38-cp38-win_amd64.whl 5. profitBoor
was missing those additional libraries on ubuntu 22. installing them allowed me to install pygraphviz on python 3.10. Thank youDmitri
How do i install it in windows without using WSL bash?Icicle
F
8

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 (like this) Unpack that. Create a 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\" pygraphviz
Farrica answered 6/2, 2017 at 1:10 Comment(4)
Here's the link at the bottom of that issues page: github.com/mahkoCosmo/GraphViz_x64. What's strange is that the repo hasn't been updated in 8 months but the release directory you're pointing towards in \Graphviz2.38\lib doesn't exist.Fork
In my case (Win 10, Python 3.6), additionalIy, had to apply a patch described here github.com/pygraphviz/pygraphviz/issues/…Busybody
This throws 'graphviz/cgraph.h' : No such file or directory.Coterminous
This works for me, but it does not work if I try to specify these options in the requirements.txt file and then read the requirements.txt file inside the setup.py file to specify the install_requires. I get an parse error at --global-option.Fogbow
P
7

None of the above worked for me, so I will show what did worked on my windows 11 machine (I don't think the windows version was the problem), which is in the pygraphviz documentation:

  1. Install Visual C/C++, from here: https://visualstudio.microsoft.com/visual-cpp-build-tools/ It shows up as a requirement and even if you did install it and try to reinstall with pip, it may not work because garphviz is another requirement.
  2. Download and install graphviz for windows: stable_windows_10_cmake_Release_x64_graphviz-install-2.46.0-win64.exe
  3. Restart your computer (as required per the first step)
  4. Then install the library pygraphviz through Windows PowerShell with the following command (I don't know why, with pip it still wasn't working):
python -m pip install --global-option=build_ext `
          --global-option="-IC:\Program Files\Graphviz\include" `
          --global-option="-LC:\Program Files\Graphviz\lib" `
          pygraphviz
Padre answered 9/11, 2021 at 21:13 Comment(1)
Works like a charm. Thank you.Heger
S
2

It is a real pain to install pygraphviz on Windows 10 but this is the simples solution which works for me:

Step 1: Download and install Graphviz

https://graphviz.gitlab.io/_pages/Download/Download_windows.html

Step 2: Add below path to your PATH environment variable

C:\Program Files (x86)\Graphviz2.38\bin

Step 3: Re-open command line and activate venv in your project, example:

venv\Scripts\activate

Step 4: Download binaries from below link:

https://github.com/CristiFati/Prebuilt-Binaries/tree/master/PyGraphviz/v1.5/Graphviz-2.42.2

Step 5. Install whl into your virtual environment

For example:

In case of python 3.7

pip install pygraphviz-1.5-cp37-cp37m-win_amd64.whl

In case of python 3.8

pip install pygraphviz-1.5-cp38-cp38-win_amd64.whl

Success answered 6/6, 2020 at 10:56 Comment(2)
thank you, your comment about adding the Graphviz path to the PATH environment variable is what finally got this working for meCreamcups
NOTICE: This does NOT work for python version > 3.8.Heger
E
2

Here's how I installed 64 bit PyGraphViz for Windows 10:

Downloaded and installed GraphViz from https://www2.graphviz.org/Packages/stable/windows/10/cmake/Release/x64/graphviz-install-2.44.1-win64.exe

Made sure I had Visual C++ installed, e.g. from here: https://visualstudio.microsoft.com/visual-cpp-build-tools/

Then I ran:

pip install --global-option=build_ext --global-option="-IC:\Program Files\Graphviz 2.44.1\include" --global-option="-LC:\Program Files\Graphviz 2.44.1\lib" pygraphviz

Then I had to add C:\Program Files\Graphviz 2.44.1\bin to my system path before import pygraphviz worked.

Finally, I had to run this in command prompt after the install to register plugins and be able to draw graphs: "C:\Program Files\Graphviz 2.44.1\bin\dot.exe" -c

Obviously, for a newer version of Graphviz you'll need to check and update all the paths given above.

Exactitude answered 15/10, 2020 at 13:0 Comment(0)
V
2

The true easiest way to install pygraphviz on Windows without conda or external packager is to use Gohlke's wheels (opinion: His works should be assumed daily by someone in the Python Software Foundation)

  1. Install latest or adapted graphviz package from graphviz using the 64bit or 32bit exe. Don't forget to check the box "add to the path"

  2. Restart the computer

  3. Download Unofficial Windows Binaries for Python Extension Packages by Christoph Gohlke from the Laboratory for Fluorescence Dynamics, University of California, Irvine.

  4. Open a terminal/powershell as admin on the folder where you downloaded the pygraphviz-version-python_version-win_version.whl and enter pip install pygraphviz-*version*-*python_version*-*win_version*.whl

  5. Test the install by opening in the terminal/powershell and entering

    python

    import pygraphviz

if no error returns, pygraphviz is installed and functional

Vulgarism answered 10/1, 2022 at 8:37 Comment(0)
H
0

Try to install from your Anaconda (Python 3.8 recommended) environment using:

conda install -c conda-forge python-graphviz

Hexangular answered 2/12, 2022 at 8:29 Comment(0)
W
0

From these answers graphviz version worked for me is

https://www2.graphviz.org/Packages/stable/windows/10/cmake/Release/x64/graphviz-install-2.44.1-win64.exe

after that I got an error :

kerras plot model AssertionError: "dot" with args ['-Tps', '..\AppData\Local\Temp\tmp334nlu__'] returned code: 1

followed below steps to fix :

1.Open CMD with administrator privileges (simply right click on the CMD and click "run as administrator")

2.Insert the command dot -c, this will configure the GraphViz plugins

Wane answered 12/12, 2022 at 10:27 Comment(0)
I
-1

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

  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

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

Instancy answered 8/11, 2018 at 7:23 Comment(1)
In the step 5, I have the error : basetsd.h not found. Any idea ?Rrhagia

© 2022 - 2024 — McMap. All rights reserved.