2

I have troubles installing pygraphviz on macOS Mojave 10.14.1. The Python version I used is 3.6.7. When executing the command pip install pygraphviz, I get the following lengthy error message:

Collecting pygraphviz
Using cached https://files.pythonhosted.org/packages/7e/b1/d6d849ddaf6f11036f9980d433f383d4c13d1ebcfc3cd09bc845bda7e433/pygraphviz-1.5.zip
Building wheels for collected packages: pygraphviz
Running setup.py bdist_wheel for pygraphviz ... error
Complete output from command /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/rn/zr6qnswn7wb886b6twbfgjym0000gn/T/pip-install-x_fr0oej/pygraphviz/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/rn/zr6qnswn7wb886b6twbfgjym0000gn/T/pip-wheel-qre51z9v --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.6
creating build/lib.macosx-10.9-x86_64-3.6/pygraphviz
copying pygraphviz/release.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz
copying pygraphviz/version.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz
copying pygraphviz/graphviz.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz
copying pygraphviz/__init__.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz
copying pygraphviz/agraph.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz
creating build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_setup.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_unicode.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_readwrite.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_string.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/__init__.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_html.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_node_attributes.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_drawing.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_subgraph.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_edge_attributes.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_clear.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_layout.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_attribute_defaults.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_graph.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_attributes.py -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz/tests
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'
copying pygraphviz/graphviz.i -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz
copying pygraphviz/graphviz_wrap.c -> build/lib.macosx-10.9-x86_64-3.6/pygraphviz
running build_ext
building 'pygraphviz._graphviz' extension
creating build/temp.macosx-10.9-x86_64-3.6
creating build/temp.macosx-10.9-x86_64-3.6/pygraphviz
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c pygraphviz/graphviz_wrap.c -o build/temp.macosx-10.9-x86_64-3.6/pygraphviz/graphviz_wrap.o
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command 'gcc' failed with exit status 1

----------------------------------------
Failed building wheel for pygraphviz
Running setup.py clean for pygraphviz
Failed to build pygraphviz
Installing collected packages: pygraphviz
Running setup.py install for pygraphviz ... error
Complete output from command /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/rn/zr6qnswn7wb886b6twbfgjym0000gn/T/pip-install-x_fr0oej/pygraphviz/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/rn/zr6qnswn7wb886b6twbfgjym0000gn/T/pip-record-kukz1ofd/install-record.txt --single-version-externally-managed --compile:
running install
Trying dpkg
Failed to find dpkg
Trying pkg-config
Failed to find pkg-config
Trying dotneato-config
Failed to find dotneato-config
Failed to find dotneato-config

Your Graphviz installation could not be found.

        1) You don't have Graphviz installed:
           Install Graphviz (http://graphviz.org)

        2) Your Graphviz package might incomplete.
           Install the binary development subpackage (e.g. libgraphviz-dev or similar.)

        3) You are using Windows
           There are no PyGraphviz binary packages for Windows but you might be
           able to build it from this source.  See
           http://networkx.lanl.gov/pygraphviz/reference/faq.html

        If you think your installation is correct you will need to manually
        provide path to graphviz include and library. For example:

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

        The current setting of library_dirs and include_dirs is:
library_dirs=None
include_dirs=None

error: Error locating graphviz.

----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/rn/zr6qnswn7wb886b6twbfgjym0000gn/T/pip-install-x_fr0oej/pygraphviz/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/rn/zr6qnswn7wb886b6twbfgjym0000gn/T/pip-record-kukz1ofd/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/rn/zr6qnswn7wb886b6twbfgjym0000gn/T/pip-install-x_fr0oej/pygraphviz/

Can anyone give me help? Thanks!

I applied the suggestion of @hoefling: xcode-select --install, and then try pip3 install pygraphviz. An error is still existing like the following pictures: enter image description here

enter image description here

enter image description here

enter image description here

JM Zhou
  • 125
  • 2
  • 13
  • try `pip3 install --install-option="--include-path=/usr/local/include/" --install-option="--library-path=/usr/local/lib/" pygraphviz` – dkb Nov 06 '18 at 08:18
  • `xcode-select --install` – hoefling Nov 06 '18 at 09:43
  • Possible duplicate of [Error on "pip install -U channels" command using for otree (Running setup.py bdist\_wheel for twisted ... error)](https://stackoverflow.com/questions/47400675/error-on-pip-install-u-channels-command-using-for-otree-running-setup-py-bdi) – phd Nov 06 '18 at 09:46
  • https://stackoverflow.com/search?q=%5Bpip%5D+xcrun%3A+error%3A+invalid+active+developer+path+missing+xcrun – phd Nov 06 '18 at 09:46
  • @dkb. This command doesn't work for me. – JM Zhou Nov 09 '18 at 14:46
  • @hoefling. What is the use of the command `xcode-select --install`? and how to do in the next step? – JM Zhou Nov 09 '18 at 14:56
  • @JMZhou, Still getting same error? if different post it in comment. – dkb Nov 09 '18 at 15:01
  • @JMZhou this is the actual error line: `xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun`. The command fixes that by installing and configuring the XCode dev tools. – hoefling Nov 09 '18 at 16:31
  • @dkb. The error is different than just using `pip install pygraphviz`. But this time, the error is : `pygraphviz/graphviz_wrap.c:2987:10: fatal error: 'graphviz/cgraph.h' file not found #include "graphviz/cgraph.h" ^~~~~~~~~~~~~~~~~~~ 1 error generated. error: command 'gcc' failed with exit status 1` – JM Zhou Nov 10 '18 at 07:03
  • @hoefling. I applied your comment, then using `pip install pygraphviz`. the same error still appears. So what is the next? – JM Zhou Nov 10 '18 at 07:10
  • Run the command again, then run `pip install` command again and add the output to the question. – hoefling Nov 12 '18 at 09:30
  • @hoefling. OK. I have posted the error information to the question. – JM Zhou Nov 13 '18 at 13:10
  • This is a completely different error, not? You're missing graphviz: `brew install graphviz` – hoefling Nov 13 '18 at 13:46
  • @hoefling. I am sure I have installed `graphviz` package. – JM Zhou Nov 14 '18 at 01:56

2 Answers2

2

The question has been done by using this command:

pip install pygraphviz --install-option="--include-path=/usr/include/graphviz" --install-option="--library-path=/usr/lib/graphviz/"
JM Zhou
  • 125
  • 2
  • 13
0

On Apple M1:

pip install --global-option=build_ext --global-option="-I/opt/homebrew/include/graphviz" --global-option="-L/opt/homebrew/Cellar/graphviz/2.46.1/lib/"  pygraphviz
Kernel
  • 661
  • 7
  • 10
  • 1
    can you explain why your answer worked and why the flags you used are needes as showned? – Charlie Parker May 12 '21 at 19:40
  • tweaked your command a bit. Mine on regular mac 12.6.1: `pip install --global-option=build_ext --global-option="-I/usr/local/Cellar/graphviz/7.0.1/include" --global-option="-L/usr/local/Cellar/graphviz/7.0.1/lib" pygraphviz` – selle Nov 16 '22 at 12:29