12

I'm unable to install pygraphviz even after installing graphviz and ensuring that cgraph.h is present in the directory.

I've also manually specified the directory for install. e.g. install-path

fatal error C1083: Cannot open include file: 'graphviz/cgraph.h': No such file or directory

Looking for any and all suggestions. Using Windows.

C:\Users\mmcgown\Desktop\School\MSDS452\pygraphviz-1.5>python setup.py install --prefix=C:\Program_Files_(x86)\Graphviz2.38 --include-path=C:\Program_Files_(x86)\Graphviz2.38\include\ --library-path=C:\Program_Files_(x86)\Graphviz2.38\lib\
running install
running build
running build_py
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'
running build_ext
building 'pygraphviz._graphviz' extension
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -IC:\Program_Files_(x86)\Graphviz2.38\include\ -IC:\Users\mmcgown\AppData\Local\Continuum\anaconda3\include -IC:\Users\mmcgown\AppData\Local\Continuum\anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /Tcpygraphviz/graphviz_wrap.c /Fobuild\temp.win-amd64-3.7\Release\pygraphviz/graphviz_wrap.obj
graphviz_wrap.c
pygraphviz/graphviz_wrap.c(2987): fatal error C1083: Cannot open include file: 'graphviz/cgraph.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
Mark McGown
  • 975
  • 1
  • 10
  • 26
  • Does this answer your question? [howto install pygraphviz on windows 10 64bit](https://stackoverflow.com/questions/40809758/howto-install-pygraphviz-on-windows-10-64bit) – nbro Jan 11 '21 at 19:16

3 Answers3

23

I installed the latest graphviz using the latest win64 executable from graphviz.org

graphviz 2.49 win64

then installation using the following command worked for me

pip install --global-option=build_ext --global-option="-IC:\Program Files\Graphviz\include" --global-option="-LC:\Program Files\Graphviz\lib" pygraphviz
codeslord
  • 2,172
  • 14
  • 20
  • Works perfectly, thanks! – Kevin Ramirez Zavalza Dec 07 '21 at 01:10
  • @KevinRamirezZavalza Let me know in comments if you face any issues in the future – codeslord Dec 09 '21 at 07:28
  • Worked for me using the latest graphviz at the time of writing (7.1.0) – Bruce Adams Feb 21 '23 at 16:33
  • didnt work for me pygraphviz/graphviz_wrap.c(2711): fatal error C1083: Cannot open include file: 'graphviz/cgraph.h': No such file or directory error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2 note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pygraphviz Failed to build pygraphviz ERROR: Could not build wheels for pygraphviz, which is required to install – Praveer Kumar Apr 19 '23 at 11:54
  • @PraveerKumar Please make sure you have visual studio and necessary build tools installed – codeslord Apr 21 '23 at 14:25
  • 1
    @codeslord Thanks for the suggestions. I had installed vs2022 community version but it did not work. Finally, I just thought to install via anaconda , and it worked for me . I really dnt know what was screwed up :( – Praveer Kumar Apr 26 '23 at 06:51
18

On Ubuntu please do
sudo apt install graphviz-dev

Ayush Bairagi
  • 254
  • 4
  • 4
6

For those who visit this page, you may already come across to this fix or this issue on GitHub and try to install GraphViz2.38 manually. But neither of them will work since GraphViz and PyGraphViz are 2 different libraries

Mac or Ubuntu already have their solutions on GitHub, however for Win10 64-bit, it does not receive any fix yet since 2018. Installing pygraphviz on Windows 10 64-bit, Python 3.6

Someone have created a build of PyGraphviz 1.5 on his Anaconda channel for Windows 64 bit running Python 3.6, Python 3.7 or Python 3.8. If you're running Anaconda, you can install with:

conda install -c alubbock pygraphviz

Please mark this as a possible duplicate with this question if someone see it.

Kit Law
  • 323
  • 6
  • 15