Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Yes, I know a discussion is here: Issues installing pygrahviz "fatal error C1083: Cannot open include file: 'graphviz/cgraph.h': No such file or directory"

But none of these solutions worked.

I used:

pip install graphviz

and also:

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

But neither of these have worked still returning:

pygraphviz/graphviz_wrap.c(3020): fatal error C1083: Cannot open include file: 'graphviz/cgraph.h': No such file or directory error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.36.32532\\bin\\HostX86\\x64\\cl.exe' failed with exit code

Also there is this warning in the command prompt but i don't know how to utilise it.

DEPRECATION: --build-option and --global-option are deprecated. pip 23.3 will enforce this behaviour change. A possible replacement is to use --config-settings. Discussion can be found at https://github.com/pypa/pip/issues/11859 WARNING: Implying --no-binary=:all: due to the presence of --build-option / --global-option.

like image 711
Tang0 Avatar asked Sep 19 '25 20:09

Tang0


1 Answers

I met the same C code compile time error as you did.

On Windows 10, pip 24.1 and python 3.12. It took me these steps to complete the installation.

  1. Download and install Graphviz: https://graphviz.org/download/

  2. Then run the following command:pi

    python -m pip install --config-settings="--global-option=build_ext" --config-settings="--global-option=-IC:\Program Files\Graphviz\include" --config-settings="--global-option=-LC:\Program Files\Graphviz\lib" pygraphviz

Note: change the -I -L path to where your graphviz is installed. Basically -I and -L give the C/C++ compiler the path to look for .h and .lib files.

like image 173
Wilson Yu Cao Avatar answered Sep 21 '25 13:09

Wilson Yu Cao