Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation:fatal error: 'graphviz/cgraph.h' file not found #11

Closed
hebijiandai opened this issue Mar 7, 2014 · 75 comments
Closed

Installation:fatal error: 'graphviz/cgraph.h' file not found #11

hebijiandai opened this issue Mar 7, 2014 · 75 comments

Comments

@hebijiandai
Copy link

I use mac os
I run the code:

python setup.py install 

But it didn't success
So I write the dirs:

include_dirs = "/Users/allenlee/Downloads/pygraphviz-master/pygraphviz"
library_dirs = "/Users/allenlee/Downloads/pygraphviz-master/pygraphviz"

But it cause the error

AllendeMacBook-Pro:pygraphviz-master allenlee$ python setup.py install
library_dirs=/Users/allenlee/Downloads/pygraphviz-master/pygraphviz
include_dirs=/Users/allenlee/Downloads/pygraphviz-master/pygraphviz
running install
running build
running build_py
running build_ext
building 'pygraphviz._graphviz' extension
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/allenlee/Downloads/pygraphviz-master/pygraphviz -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pygraphviz/graphviz_wrap.c -o build/temp.macosx-10.6-intel-2.7/pygraphviz/graphviz_wrap.o
pygraphviz/graphviz_wrap.c:2969:10: fatal error: 'graphviz/cgraph.h' file not found
#include "graphviz/cgraph.h"
         ^

Could you help to solve it?Thanks a lot

@bugamn
Copy link

bugamn commented Mar 7, 2014

Do you have the graphviz development files installed? On Ubuntu, for example, they are in a package called libgraphviz-dev. I don't know how one would install them on a Mac.

@hebijiandai
Copy link
Author

I use pip install graphviz to install it ,maybe graphviz is the key point of this error

@bugamn
Copy link

bugamn commented Mar 7, 2014

Can you remove the dirs you wrote and post the error message?

EDIT: the dirs that you added should have the graphviz files (not pygraphviz). It seems that the problem is that you need to install graphviz, which isn't a python package, so I don't see how you would install it with pip.

Download link for MacOS graphviz: http://www.graphviz.org/Download_macos.php

@hebijiandai
Copy link
Author

OK ,I finish the job,thanks a lot!

@hagberg hagberg closed this as completed Sep 21, 2014
@whu-zhigao
Copy link

How did you solve this problem? I have the same situation with you but I use windows 7

@whu-zhigao
Copy link

I use Windoews 7 OS
It cause the error:
D:\mingw-get\bin\gcc.exe -mdll -O -Wall -DGVDLL -ID:\Python34\include -ID:\Pytho
n34\include -c pygraphviz/graphviz_wrap.c -o build\temp.win32-3.4\Release\pygrap
hviz\graphviz_wrap.o
pygraphviz/graphviz_wrap.c:2954:29: fatal error: graphviz/cgraph.h: No such file
or directory
#include "graphviz/cgraph.h"
^
compilation terminated.
error: command 'D:\mingw-get\bin\gcc.exe' failed with exit status 1

@hagberg hagberg modified the milestone: pygraphivz-1.3 Sep 5, 2015
@AgalyaLoganathan
Copy link

Hi,
I'm using yosemite and I have installed grapghviz using Homebrew. But when I try to run 'pip install pygraphviz', I still encounter the same issue. (i.e)

pygraphviz/graphviz_wrap.c:2954:10: fatal error: 'graphviz/cgraph.h' file not found
#include "graphviz/cgraph.h"
^
1 error generated.
error: command 'cc' failed with exit status 1

----------------------------------------

Command "/usr/bin/python -c "import setuptools, tokenize;file='/private/var/folders/sj/yk1843h92lsgdxvzbvjxhk_80000gn/T/pip-build-KIO55c/pygraphviz/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /var/folders/sj/yk1843h92lsgdxvzbvjxhk_80000gn/T/pip-SwBY6j-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/sj/yk1843h92lsgdxvzbvjxhk_80000gn/T/pip-build-KIO55c/pygraphviz

Can you please elaborate on how to resolve the issue?

@saltthehash
Copy link

Having the same problem as @AgalyaLoganathan on OS X 10.11 El Capitan

EDIT: I managed to fix it by doing two things:

  1. Install pygraphviz from setup.py like so:
    python setup.py install --include-path=/usr/local/Cellar/graphviz/2.38.0/include --library-path=/usr/local/Cellar/graphviz/2.38.0/lib
    I saw a note about issues detecting the path and the example given on the website I was looking at still didn't work because it had the include directory to "include" /graphviz, which is why it could not detect "graphviz/graphviz/cgraph.h". Just double check that this is the same version of graphviz (obviously this particular path is specific to OS X users using homebrew, but making sure that the correct path for lib and include is probably useful)
  2. Make sure pydot2 is installed, and NOT pydot. After uninstalling pydot and installing pydot2, everything started working fine.

@a-ruzin
Copy link

a-ruzin commented Dec 11, 2015

My problem was:

pip install pygraphviz
....
#include "graphviz/cgraph.h"
^
1 error generated.
error: command 'cc' failed with exit status 1
....

Fixed with:

/usr/local/Cellar/graphviz/2.38.0/include/graphviz> ln -s . graphviz

pip install pygraphviz
...
Successfully installed pygraphviz-1.3.1

@thedimlebowski
Copy link

Can be solved with

pip install --global-option=build_ext --global-option="-I/usr/local/Cellar/graphviz/2.38.0/include/"  --global-option="-L/usr/local/Cellar/graphviz/2.38.0/lib/" pygraphviz

Or with: (credits to http://www.alexandrejoseph.com/blog/2016-02-10-install-pygraphviz-mac-osx.html)

pip install --install-option="--include-path=/usr/local/Cellar/graphviz/2.38.0/include/graphviz"  --install-option="--library-path=/usr/local/Cellar/graphviz/2.38.0/lib/graphviz" pygraphviz

@drandreaskrueger
Copy link

pip install pygraphviz

Windows 7

----------------------------------------
Failed building wheel for pygraphviz

Running setup.py install for pygraphviz
Complete output from command c:\anaconda\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\andreas\\appdata\\local\\temp\\pip-build-gjzf2d\\pygraphviz\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\andreas\appdata\local\temp\pip-nqpkoi-record\install-record.txt --single-version-externally-managed --compile:

...

building 'pygraphviz._graphviz' extension
C:\Users\Andreas\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -INone -Ic:\anaconda\include -Ic:\anaconda\PC /Tcpygraphviz/graphviz_wrap.c /Fobuild\temp.win-amd64-2.7\Release\pygraphviz/graphviz_wrap.obj 
graphviz_wrap.c
pygraphviz/graphviz_wrap.c(2954) : fatal error C1083: Cannot open include file: 'graphviz/cgraph.h': No such file or directory
error: command 'C:\\Users\\Andreas\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2

@hagberg
Copy link
Contributor

hagberg commented Jan 17, 2016

The original post was about mac os.

But with your windows install attempt either you are missing the graphviz package (or parts of it) or else the pygraphviz setup code is not finding your graphviz installation and you may need to explicitly set that.

@drandreaskrueger
Copy link

Thanks a lot. Yes:

http://graphviz.org/Download_windows.php

Then I could solve riddles, one after the other ...
Using your command as inspiration, transposed to windows:

pip install --global-option=build_ext --global-option="-IC:\PROGRA~2\Graphviz2.38\include"  --global-option="-LC:\PROGRA~2\Graphviz2.38\lib\release\lib" pygraphviz

but now I get "49 unresolved externals"

    C:\Users\Andreas\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\PROGRA~2\Graphviz2.38\lib\release\lib /LIBPATH:c:\anaconda\libs /LIBPATH:c:\anaconda\PCbuild\amd64 /LIBPATH:c:\anaconda\PC\VS9.0\amd64 cgraph.lib cdt.lib /EXPORT:init_graphviz build\temp.win-amd64-2.7\Release\pygraphviz/graphviz_wrap.obj /OUT:build\lib.win-amd64-2.7\pygraphviz\_graphviz.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\pygraphviz\_graphviz.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\pygraphviz\_graphviz.pyd.manifest
graphviz_wrap.obj : warning LNK4197: export 'init_graphviz' specified multiple times; using first specification
   Creating library build\temp.win-amd64-2.7\Release\pygraphviz\_graphviz.lib and object build\temp.win-amd64-2.7\Release\pygraphviz\_graphviz.exp
graphviz_wrap.obj : error LNK2019: unresolved external symbol agsafeset referenced in function agsafeset_label
graphviz_wrap.obj : error LNK2019: unresolved external symbol agstrdup_html referenced in function agsafeset_label
...
graphviz_wrap.obj : error LNK2019: unresolved external symbol Agundirected referenced in function Swig_var_Agundirected_get
graphviz_wrap.obj : error LNK2019: unresolved external symbol Agstrictundirected referenced in function Swig_var_Agstrictundirected_get
build\lib.win-amd64-2.7\pygraphviz\_graphviz.pyd : fatal error LNK1120: 49 unresolved externals
error: command 'C:\\Users\\Andreas\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\link.exe' failed with exit status 1120

@steven7777
Copy link

On Mac OS 10.11.3, using macport, solved this issue with :

pip install --install-option="--include-path=/opt/local/include" --install-option="--library-path=/opt/local/lib" pygraphviz

@jiangpengnju
Copy link

@steven7777
The "include-path" and "install-option" depend on how you installed the graphviz.
I uses brew to install graphviz and the paths are: "/usr/local/include", "/usr/local/lib"

@manthis
Copy link

manthis commented Aug 3, 2016

@steven7777 @jiangpengnju

I'm on Mac OS 10.11.6. When I try setting up pygraphviz through pip it tells me it can't find graphviz. When I specify the library and include path it doesn't recognize the options. I have opened an issue here: #100.

How did you solve this problem?

@jiangpengnju
Copy link

@manthis Already answer you in you issue #100

@Puertarra
Copy link

Tks @Steven777
It works on 10.12.1 as well

pip install --install-option="--include-path=/opt/local/include" --install-option="--library-path=/opt/local/lib" pygraphviz

@jason-s
Copy link

jason-s commented Jan 14, 2017

this worked for me: I have Mac OS X 10.6 (Snow Leopard) and the problem was that the default include path was set to /opt/local/include/graphviz and caused this error during compilation:

pygraphviz/graphviz_wrap.c:2954:29: error: graphviz/cgraph.h: No such file or directory

which is stupid because the default include path is not consistent, it needed to remove the last graphviz part of the path since the #include "graphviz/cgraph.h" is relative to the include path.

Fixed via

sudo pip install pygraphviz --global-option=build_ext --global-option="-I/opt/local/include"

@vikmary
Copy link

vikmary commented Feb 9, 2017

brew install graphviz
python setup.py install
fixed the issue for me (Mac).

@manum
Copy link

manum commented Oct 5, 2017

I had a problem due to El Capitan https://arstechnica.com/gadgets/2015/09/os-x-10-11-el-capitan-the-ars-technica-review/8/#h1

solved it by adding --user to pip

pip install --user --install-option="--include-path=/opt/local/include" --install-option="--library-path=/opt/local/lib" pygraphviz

@litchfield
Copy link

This worked for me on Mojave.

Step 1.
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/Cellar/graphviz/2.40.1/include/graphviz/

Step 2.
pip install pygraphviz

@ikarthikng
Copy link

I followed below steps

apt-get update
apt-get install libgraphviz-dev
pip install pygraphviz

It worked for me

@drozdowsky
Copy link

Catalina (10.15.2)

brew install graphviz
pip install --install-option="--include-path=/usr/local/Cellar/graphviz/2.42.2/include/"  --install-option="--library-path=/usr/local/Cellar/graphviz/2.42.2/lib/" pygraphviz

@felipebsouza
Copy link

Catalina (10.15.2)

brew install graphviz
pip install --install-option="--include-path=/usr/local/Cellar/graphviz/2.42.2/include/"  --install-option="--library-path=/usr/local/Cellar/graphviz/2.42.2/lib/" pygraphviz

worked for me too! thanks

@tgrushka
Copy link

Only thing that worked for me is @bwagner 's final comment after trying dozens of different options. Please add to the install docs for macOS Sonoma.

pip install --no-cache-dir \
  --config-settings="--global-option=build_ext" \
  --config-settings="--global-option=-I$(brew --prefix graphviz)/include/" \
  --config-settings="--global-option=-L$(brew --prefix graphviz)/lib/" \
  pygraphviz

@rossbar
Copy link
Contributor

rossbar commented Jan 11, 2024

Note that this is what is currently recommended in the installation guide - if there are any additional tweaks required please raise an issue about it!

@jmkacz
Copy link

jmkacz commented Feb 18, 2024

Following the installation guide fails for me. I posted an issue on pypa/pip before finding this issue: pypa/pip#12531

@roskakori
Copy link

I did this to make it work:

  1. Add these lines to my ~/.zprofile (resp. ~/.profile if you are still using bash).
    # Required to build pygraphviz
    export CFLAGS="-I$(brew --prefix graphviz)/include/"                                                   
    export LDFLAGS="-L$(brew --prefix graphviz)/lib/"
  2. Open a new terminal (so new envvars are set).
  3. Retry to build/install pygraphviz.

This worked for me.

@bwagner
Copy link

bwagner commented Feb 22, 2024

Adding these environment variables globally and permanently to your environment is like wearing ski gear everywhere you go just because you occasionally go skiing.
These variables need only be set for the task at hand (building/installing pygraphviz), not for all shell invocations from here on out.

@roskakori
Copy link

That may be but I found setting them globally advantageous if you have multiple projects that use pythongraphviz, if you have to occasionally rebuild your poetry environment from scratch because PyCharm screwed it up, if brew chokes and needs a reinstall every now and then, and if you just try to keep you dev environment up to date without constantly breaking things.

YMMV but I found myself too often looking up how to fix this compile error, and being presented with different search results as time passes but the compile error remains.

But yes, if you have the patience to live with the variables passed to a single call, it's certainly less intrusive.

@RijndertAriese
Copy link

Only thing that worked for me is @bwagner 's final comment after trying dozens of different options. Please add to the install docs for macOS Sonoma.

pip install --no-cache-dir \
  --config-settings="--global-option=build_ext" \
  --config-settings="--global-option=-I$(brew --prefix graphviz)/include/" \
  --config-settings="--global-option=-L$(brew --prefix graphviz)/lib/" \
  pygraphviz

Still works for me! Thaanks!

QuinnyPig added a commit to QuinnyPig/ros2_documentation that referenced this issue Mar 28, 2024
Latest version of pip is needed, as well as a few config flags to show where to find graphviz (pygraphviz/pygraphviz#11 is somehow still helpful / relevant this many years on...)

Signed-off-by: Corey Quinn <QuinnyPig@users.noreply.github.com>
clalancette added a commit to ros2/ros2_documentation that referenced this issue Apr 11, 2024
* Updates for modern macOS dev

Latest version of pip is needed, as well as a few config flags to show where to find graphviz (pygraphviz/pygraphviz#11 is somehow still helpful / relevant this many years on...)

Signed-off-by: Corey Quinn <QuinnyPig@users.noreply.github.com>
Co-authored-by: Chris Lalancette <clalancette@gmail.com>
mergify bot pushed a commit to ros2/ros2_documentation that referenced this issue Apr 11, 2024
* Updates for modern macOS dev

Latest version of pip is needed, as well as a few config flags to show where to find graphviz (pygraphviz/pygraphviz#11 is somehow still helpful / relevant this many years on...)

Signed-off-by: Corey Quinn <QuinnyPig@users.noreply.github.com>
Co-authored-by: Chris Lalancette <clalancette@gmail.com>
(cherry picked from commit 1de6ff9)

# Conflicts:
#	source/Installation/Alternatives/macOS-Development-Setup.rst
mergify bot pushed a commit to ros2/ros2_documentation that referenced this issue Apr 11, 2024
* Updates for modern macOS dev

Latest version of pip is needed, as well as a few config flags to show where to find graphviz (pygraphviz/pygraphviz#11 is somehow still helpful / relevant this many years on...)

Signed-off-by: Corey Quinn <QuinnyPig@users.noreply.github.com>
Co-authored-by: Chris Lalancette <clalancette@gmail.com>
(cherry picked from commit 1de6ff9)

# Conflicts:
#	source/Installation/Alternatives/macOS-Development-Setup.rst
clalancette pushed a commit to ros2/ros2_documentation that referenced this issue Apr 11, 2024
* Updates for modern macOS dev (#4242)

* Updates for modern macOS dev

Latest version of pip is needed, as well as a few config flags to show where to find graphviz (pygraphviz/pygraphviz#11 is somehow still helpful / relevant this many years on...)

Signed-off-by: Corey Quinn <QuinnyPig@users.noreply.github.com>
Co-authored-by: Chris Lalancette <clalancette@gmail.com>
(cherry picked from commit 1de6ff9)
clalancette pushed a commit to ros2/ros2_documentation that referenced this issue Apr 11, 2024
* Updates for modern macOS dev (#4242)

* Updates for modern macOS dev

Latest version of pip is needed, as well as a few config flags to show where to find graphviz (pygraphviz/pygraphviz#11 is somehow still helpful / relevant this many years on...)

Signed-off-by: Corey Quinn <QuinnyPig@users.noreply.github.com>
Co-authored-by: Chris Lalancette <clalancette@gmail.com>
(cherry picked from commit 1de6ff9)
@jwhendy
Copy link

jwhendy commented Apr 16, 2024

All of the above looks like workarounds. Does anyone know where this would actually be fixed? If here, why is it closed (I'm happy to open a new issue if helpful). If brew, why put more effort here vs. getting brew to address? I'm also happy to take this up with brew, I just don't have the context to understand why this is a thing/where the root cause lies.

@KSH-KOR
Copy link

KSH-KOR commented Jul 2, 2024

@bwagner pointed out that the solution below may not work for everyone and already gave a solution that tackles it better. So try the #11 (comment)

--

  1. Set Environment Variables:
    Open your terminal and set the CPATH and LIBRARY_PATH environment variables:
export CPATH=/opt/homebrew/include
export LIBRARY_PATH=/opt/homebrew/lib
  1. Install pygraphviz:
    Use the following command to install pygraphviz with the specified paths:
    pip install pygraphviz --global-option=build_ext --global-option="-I/opt/homebrew/include" --global-option="-L/opt/homebrew/lib"
  • If you still encounter issues, consider providing the full path to the graphviz directory and specifying it explicitly:
    pip install pygraphviz --global-option=build_ext --global-option="-I/opt/homebrew/include/graphviz" --global-option="-L/opt/homebrew/lib"

@Nish9
Copy link

Nish9 commented Jul 4, 2024

^ This worked for me on m1 mac too, thanks a lot!

@bwagner
Copy link

bwagner commented Jul 7, 2024

Why provide a brittle solution when there's already a functional one? Did you try the previous solution?

Here's why providing -I/opt/homebrew/include and -L/opt/homebrew/lib is an inferior choice to I$(brew --prefix graphviz)/include/ and I$(brew --prefix graphviz)/lib/: When someone uses another than the standard homebrew installation location, your instructions will fail.

In addition, following your instructions causes warnings:

DEPRECATION: --build-option and --global-option are deprecated. pip 24.2 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.
...
WARNING: Ignoring --global-option when building pygraphviz using PEP 517

@KSH-KOR
Copy link

KSH-KOR commented Jul 9, 2024

Dear @bwagner,
Thank you for pointing out the vulnerable points that I missed!

@ozturkcemal
Copy link

EDIT: thanks to atul016 for pointing out the omissions of /include and /lib in my solution.

Note: I'm using pip install-option --no-cache-dir to reproduce the uninstalled situation.

I assume you did: brew install graphviz.

python -Vis Python 3.12.0

macOS: 14.1.1 (Sonoma) on a MacBook Pro with Apple M1 Max

Before the experiments, create a virtual env and activate it, to create reproducible situation:

python -m venv ~/venv/pgv
source ~/venv/pgv/bin/activate
pip install --upgrade pip
  1. pip install --no-cache-dir pygraphviz

fails with:

      pygraphviz/graphviz_wrap.c:3020:10: fatal error: 'graphviz/cgraph.h' file not found
       3020 | #include "graphviz/cgraph.h"
            |          ^~~~~~~~~~~~~~~~~~~
      1 error generated.
      error: command '/opt/homebrew/opt/llvm/bin/clang' failed with exit code 1
  1. @chadbrewbaker ( == official instructions)
python3 -m pip install  --no-cache-dir --use-pep517 \
                    --config-settings="--global-option=build_ext" \
                    --config-settings="--build-option=-I$(brew --prefix graphviz)/include/" \
                    --config-settings="--build-option=-L$(brew --prefix graphviz)/lib/" \
                    pygraphviz

fails with the same error:

      pygraphviz/graphviz_wrap.c:3020:10: fatal error: 'graphviz/cgraph.h' file not found
       3020 | #include "graphviz/cgraph.h"
            |          ^~~~~~~~~~~~~~~~~~~
      1 error generated.
      error: command '/opt/homebrew/opt/llvm/bin/clang' failed with exit code 1
  1. CFLAGS=-I$(brew --prefix graphviz) LDFLAGS=-L$(brew --prefix graphviz) pip --no-cache-dir install pygraphviz

fails with the same error:

      pygraphviz/graphviz_wrap.c:3020:10: fatal error: 'graphviz/cgraph.h' file not found
       3020 | #include "graphviz/cgraph.h"
            |          ^~~~~~~~~~~~~~~~~~~
      1 error generated.
      error: command '/opt/homebrew/opt/llvm/bin/clang' failed with exit code 1
  1. install from local clone of pygraphviz succeeds
git clone https://github.com/pygraphviz/pygraphviz
cd pygraphviz

CFLAGS=-I$(brew --prefix graphviz)/include LDFLAGS=-L$(brew --prefix graphviz)/lib pip --no-cache-dir install .

Processing /.../pygraphviz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pygraphviz
  Building wheel for pygraphviz (pyproject.toml) ... done
  Created wheel for pygraphviz: filename=pygraphviz-1.12rc0.dev0-cp312-cp312-macosx_13_0_arm64.whl size=101213 sha256=382a0bd25f706c3c102586d9299d371965d4891609a92beacf9a098814745bce
  Stored in directory: /private/var/folders/zv/czfq38716j5417j45s_n94sc0000gr/T/pip-ephem-wheel-cache-e2tqh68a/wheels/f3/6a/9b/90428baf90719073e8a9dee6858613fb16110ed695d25bb83c
Successfully built pygraphviz
Installing collected packages: pygraphviz
Successfully installed pygraphviz-1.12rc0.dev0

life saver

@sitatec
Copy link

sitatec commented Jul 29, 2024

Thanks to the @ozturkcemal's answer this worked for me:
CFLAGS=-I$(brew --prefix graphviz)/include LDFLAGS=-L$(brew --prefix graphviz)/lib pip --no-cache-dir install pygraphviz
No need to clone the pygraphviz repo but you must have graphviz install (e.g: brew install graphviz)

@bwagner
Copy link

bwagner commented Oct 4, 2024

Using mise to maintain different Python versions, @sitatec's approach didn't cut it for me, but my previous solution did. (cloning the repo ceased being necessary for a while now). Repeated here:

pip install \
  --config-settings="--global-option=build_ext" \
  --config-settings="--global-option=-I$(brew --prefix graphviz)/include/" \
  --config-settings="--global-option=-L$(brew --prefix graphviz)/lib/" \
  pygraphviz

Python: 3.12.4
macOS: Sequoia 15.0.1

@marcwebbie
Copy link

This worked for me with poetry on a mac with brew

brew install graphviz
export GRAPHVIZ_PREFIX=$(brew --prefix graphviz)
export CFLAGS="-I${GRAPHVIZ_PREFIX}/include"
export LDFLAGS="-L${GRAPHVIZ_PREFIX}/lib"
poetry add pygraphviz

Python: 3.12.7
masOS: Sonoma 14.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests