Error while installing pygraphviz on OS X with Anaconda
<p>I am trying to install pygraphviz in OS X 10.9.5. I am using Python 2.7.12  with Anaconda 2.1.0. I already have graphviz installed. </p>

<p>Here is the error I get when running pip install pygraphviz  </p>

<pre><code>  #include "graphviz/cgraph.h"
                               ^
  compilation terminated.
  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 /Users/safsafi/anaconda/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/vv/w5df7gw55bz_8bry85xf18rh0000gn/T/pip-build-QsLsqM/pygraphviz/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/vv/w5df7gw55bz_8bry85xf18rh0000gn/T/pip-_MkJKV-record/install-record.txt --single-version-externally-managed --compile:
    running install
    Trying pkg-config
    Package libcgraph was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libcgraph.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libcgraph' found
    Traceback (most recent call last):
      File "&lt;string&gt;", line 1, in &lt;module&gt;
      File "/private/var/folders/vv/w5df7gw55bz_8bry85xf18rh0000gn/T/pip-build-QsLsqM/pygraphviz/setup.py", line 87, in &lt;module&gt;
        tests_require=['nose&gt;=0.10.1', 'doctest-ignore-unicode&gt;=0.1.0',],
      File "/Users/safsafi/anaconda/lib/python2.7/distutils/core.py", line 151, in setup
        dist.run_commands()
      File "/Users/safsafi/anaconda/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/Users/safsafi/anaconda/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "setup_commands.py", line 44, in modified_run
        self.include_path, self.library_path = get_graphviz_dirs()
      File "setup_extra.py", line 121, in get_graphviz_dirs
        include_dirs, library_dirs = _pkg_config()
      File "setup_extra.py", line 44, in _pkg_config
        output = S.check_output(['pkg-config', '--libs-only-L', 'libcgraph'])
      File "/Users/safsafi/anaconda/lib/python2.7/subprocess.py", line 574, in check_output
        raise CalledProcessError(retcode, cmd, output=output)
    subprocess.CalledProcessError: Command '['pkg-config', '--libs-only-L', 'libcgraph']' returned non-zero exit status 1

    ----------------------------------------
Command "/Users/safsafi/anaconda/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/vv/w5df7gw55bz_8bry85xf18rh0000gn/T/pip-build-QsLsqM/pygraphviz/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/vv/w5df7gw55bz_8bry85xf18rh0000gn/T/pip-_MkJKV-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/vv/w5df7gw55bz_8bry85xf18rh0000gn/T/pip-build-QsLsqM/pygraphviz/
</code></pre>

<p>I have also tried running : </p>

<pre><code>conda install --channel https://conda.anaconda.org/garylschultz pygraphviz
</code></pre>

<p>Which does not give any error but import pygraphviz still don't work in python. </p>

<p>When I try import pygraphviz in python I get the following error: </p>

<pre><code>Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/Users/safsafi/anaconda/lib/python2.7/site-packages/pygraphviz/__init__.py", line 54, in &lt;module&gt;
    from agraph import AGraph, Node, Edge, Attribute, ItemAttribute
  File "/Users/safsafi/anaconda/lib/python2.7/site-packages/pygraphviz/agraph.py", line 20, in &lt;module&gt;
    import graphviz as gv
  File "/Users/safsafi/anaconda/lib/python2.7/site-packages/pygraphviz/graphviz.py", line 7, in &lt;module&gt;
    import _graphviz
ImportError: dlopen(/Users/safsafi/anaconda/lib/python2.7/site-packages/pygraphviz/_graphviz.so, 2): Library not loaded: /opt/local/lib/libcgraph.6.dylib
  Referenced from: /Users/safsafi/anaconda/lib/python2.7/site-packages/pygraphviz/_graphviz.so
  Reason: image not found
</code></pre>

<p>Thanks in advance.</p>

<p>On Mac OSX, I solve it with:</p>

<pre><code>pip install graphviz
pip install --install-option="--include-path=/opt/local/include" --install-option="--library-path=/opt/local/lib" pygraphviz
</code></pre>

<p>GitHub related <a href="https://github.com/pygraphviz/pygraphviz/issues/11" rel="nofollow">issue</a></p>

python python-2.7 anaconda