[GH-ISSUE #183] Install fails on Mac due to pygraphviz #111

Closed
opened 2026-05-06 12:37:34 +02:00 by BreizhHardware · 3 comments

Originally created by @snemetz on GitHub (Apr 1, 2026).
Original GitHub issue: https://github.com/patrickchugh/terravision/issues/183

MacOS 26.2
Python 3.14.3

Tried pipx and install using requirement file. Both report same issue

      building 'pygraphviz._graphviz' extension
      creating build/temp.macosx-26.0-arm64-cpython-314/pygraphviz
      clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -DSWIG_PYTHON_STRICT_BYTE_CHAR -I/Users/steven.nemetz/Documents/Wisk-Projects/github/patrickchugh/terravision/include -I/opt/homebrew/opt/python@3.14/Frameworks/Python.framework/Versions/3.14/include/python3.14 -c pygraphviz/graphviz_wrap.c -o build/temp.macosx-26.0-arm64-cpython-314/pygraphviz/graphviz_wrap.o
      pygraphviz/graphviz_wrap.c:9:9: warning: 'SWIG_PYTHON_STRICT_BYTE_CHAR' macro redefined [-Wmacro-redefined]
          9 | #define SWIG_PYTHON_STRICT_BYTE_CHAR
            |         ^
      <command line>:2:9: note: previous definition is here
          2 | #define SWIG_PYTHON_STRICT_BYTE_CHAR 1
            |         ^
      pygraphviz/graphviz_wrap.c:3023:10: fatal error: 'graphviz/cgraph.h' file not found
       3023 | #include "graphviz/cgraph.h"
            |          ^~~~~~~~~~~~~~~~~~~
      1 warning and 1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

  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: failed-wheel-build-for-install

× Failed to build installable wheels for some pyproject.toml based projects
╰─> pygraphviz

While they both report the above, pipx log file also had this

  Building wheel for pygraphviz (pyproject.toml): finished with status 'error'
Failed to build pygraphviz

PIP STDERR
----------
  error: subprocess-exited-with-error

  × Building wheel for pygraphviz (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [100 lines of output]
      /private/var/folders/x2/pgvmh6817kq5d7gfvrx27nqm0000gq/T/pip-build-env-gto839l2/overlay/lib/python3.14/site-packages/setuptools/config/_apply_pyprojecttoml.py:82: SetuptoolsDeprecationWarning: `project.license` as a TOML table is deprecated
      !!

              ********************************************************************************
              Please use a simple string containing a SPDX expression for `project.license`. You can also use `project.license-files`. (Both options available on setuptools>=77.0.0).

              By 2027-Feb-18, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.

              See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
              ********************************************************************************

      !!
        corresp(dist, value, root_dir)
      /private/var/folders/x2/pgvmh6817kq5d7gfvrx27nqm0000gq/T/pip-build-env-gto839l2/overlay/lib/python3.14/site-packages/setuptools/config/_apply_pyprojecttoml.py:61: SetuptoolsDeprecationWarning: License classifiers are deprecated.
Originally created by @snemetz on GitHub (Apr 1, 2026). Original GitHub issue: https://github.com/patrickchugh/terravision/issues/183 MacOS 26.2 Python 3.14.3 Tried pipx and install using requirement file. Both report same issue ``` building 'pygraphviz._graphviz' extension creating build/temp.macosx-26.0-arm64-cpython-314/pygraphviz clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -DSWIG_PYTHON_STRICT_BYTE_CHAR -I/Users/steven.nemetz/Documents/Wisk-Projects/github/patrickchugh/terravision/include -I/opt/homebrew/opt/python@3.14/Frameworks/Python.framework/Versions/3.14/include/python3.14 -c pygraphviz/graphviz_wrap.c -o build/temp.macosx-26.0-arm64-cpython-314/pygraphviz/graphviz_wrap.o pygraphviz/graphviz_wrap.c:9:9: warning: 'SWIG_PYTHON_STRICT_BYTE_CHAR' macro redefined [-Wmacro-redefined] 9 | #define SWIG_PYTHON_STRICT_BYTE_CHAR | ^ <command line>:2:9: note: previous definition is here 2 | #define SWIG_PYTHON_STRICT_BYTE_CHAR 1 | ^ pygraphviz/graphviz_wrap.c:3023:10: fatal error: 'graphviz/cgraph.h' file not found 3023 | #include "graphviz/cgraph.h" | ^~~~~~~~~~~~~~~~~~~ 1 warning and 1 error generated. error: command '/usr/bin/clang' failed with exit code 1 [end of output] 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: failed-wheel-build-for-install × Failed to build installable wheels for some pyproject.toml based projects ╰─> pygraphviz ``` While they both report the above, pipx log file also had this ``` Building wheel for pygraphviz (pyproject.toml): finished with status 'error' Failed to build pygraphviz PIP STDERR ---------- error: subprocess-exited-with-error × Building wheel for pygraphviz (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [100 lines of output] /private/var/folders/x2/pgvmh6817kq5d7gfvrx27nqm0000gq/T/pip-build-env-gto839l2/overlay/lib/python3.14/site-packages/setuptools/config/_apply_pyprojecttoml.py:82: SetuptoolsDeprecationWarning: `project.license` as a TOML table is deprecated !! ******************************************************************************** Please use a simple string containing a SPDX expression for `project.license`. You can also use `project.license-files`. (Both options available on setuptools>=77.0.0). By 2027-Feb-18, you need to update your project and remove deprecated calls or your builds will no longer be supported. See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details. ******************************************************************************** !! corresp(dist, value, root_dir) /private/var/folders/x2/pgvmh6817kq5d7gfvrx27nqm0000gq/T/pip-build-env-gto839l2/overlay/lib/python3.14/site-packages/setuptools/config/_apply_pyprojecttoml.py:61: SetuptoolsDeprecationWarning: License classifiers are deprecated. ```
Author
Owner

@snemetz commented on GitHub (Apr 1, 2026):

Found this and it allowed me to get it installed

export CFLAGS="-I$(brew --prefix graphviz)/include/"
export LDFLAGS="-L$(brew --prefix graphviz)/lib/"
pip install pygraphviz
<!-- gh-comment-id:4166634516 --> @snemetz commented on GitHub (Apr 1, 2026): Found this and it allowed me to get it installed ``` export CFLAGS="-I$(brew --prefix graphviz)/include/" export LDFLAGS="-L$(brew --prefix graphviz)/lib/" pip install pygraphviz ```
Author
Owner

@patrickchugh commented on GitHub (Apr 3, 2026):

Thanks for reporting this @snemetz! This is a known issue on macOS where pygraphviz (a transitive dependency via graphviz2drawio) needs to compile a C extension but can't find the Graphviz headers.

Your workaround with CFLAGS/LDFLAGS is correct. We've now added an install script that automates this — it detects your Graphviz installation automatically whether you're using Homebrew, MacPorts, or a manual install:

curl -sSL https://raw.githubusercontent.com/patrickchugh/terravision/main/install.sh | bash

The script checks (in order):

  1. pkg-config — works with any package manager
  2. Homebrew (brew --prefix graphviz)
  3. MacPorts (/opt/local)
  4. Common system paths (/usr/local, /usr)

On Linux this isn't needed since package managers install headers to standard paths. This only affects macOS where Graphviz headers end up in non-standard locations.

Let us know if this helps!

<!-- gh-comment-id:4183273834 --> @patrickchugh commented on GitHub (Apr 3, 2026): Thanks for reporting this @snemetz! This is a known issue on macOS where `pygraphviz` (a transitive dependency via `graphviz2drawio`) needs to compile a C extension but can't find the Graphviz headers. Your workaround with `CFLAGS`/`LDFLAGS` is correct. We've now added an install script that automates this — it detects your Graphviz installation automatically whether you're using Homebrew, MacPorts, or a manual install: ```bash curl -sSL https://raw.githubusercontent.com/patrickchugh/terravision/main/install.sh | bash ``` The script checks (in order): 1. `pkg-config` — works with any package manager 2. Homebrew (`brew --prefix graphviz`) 3. MacPorts (`/opt/local`) 4. Common system paths (`/usr/local`, `/usr`) On Linux this isn't needed since package managers install headers to standard paths. This only affects macOS where Graphviz headers end up in non-standard locations. Let us know if this helps!
Author
Owner

@patrickchugh commented on GitHub (Apr 3, 2026):

Thanks for reporting this @snemetz. This is a known issue with pygraphviz on macOS — it needs Graphviz C headers at compile time, and on Apple Silicon Macs Homebrew installs to /opt/homebrew/ which isn't in the default compiler search path.

We've updated TerraVision so that pygraphviz (needed only for draw.io export) is no longer a required dependency on macOS or Windows. A standard install now works cleanly on all platforms:

pip install terravision

If you need draw.io export, install the optional extra with the Graphviz header flags:

# Apple Silicon Mac (M1/M2/M3/M4)
export CFLAGS="-I$(brew --prefix graphviz)/include/"
export LDFLAGS="-L$(brew --prefix graphviz)/lib/"
pip install 'terravision[drawio]'

# Intel Mac — works directly
pip install 'terravision[drawio]'

This will be included in the next release. Thanks for the workaround you posted — that's exactly the right fix for the underlying pygraphviz build issue.

<!-- gh-comment-id:4183323043 --> @patrickchugh commented on GitHub (Apr 3, 2026): Thanks for reporting this @snemetz. This is a known issue with `pygraphviz` on macOS — it needs Graphviz C headers at compile time, and on Apple Silicon Macs Homebrew installs to `/opt/homebrew/` which isn't in the default compiler search path. We've updated TerraVision so that `pygraphviz` (needed only for draw.io export) is no longer a required dependency on macOS or Windows. A standard install now works cleanly on all platforms: ```bash pip install terravision ``` If you need draw.io export, install the optional extra with the Graphviz header flags: ```bash # Apple Silicon Mac (M1/M2/M3/M4) export CFLAGS="-I$(brew --prefix graphviz)/include/" export LDFLAGS="-L$(brew --prefix graphviz)/lib/" pip install 'terravision[drawio]' # Intel Mac — works directly pip install 'terravision[drawio]' ``` This will be included in the next release. Thanks for the workaround you posted — that's exactly the right fix for the underlying `pygraphviz` build issue.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/terravision#111
No description provided.