【问题标题】:Error while installing pygraphviz on OS X with Anaconda使用 Anaconda 在 OS X 上安装 pygraphviz 时出错
【发布时间】:2016-10-06 10:46:24
【问题描述】:

我正在尝试在 OS X 10.9.5 中安装 pygraphviz。我正在使用 Python 2.7.12 和 Anaconda 2.1.0。我已经安装了graphviz。

这是我在运行 pip install pygraphviz 时遇到的错误

  #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 "<string>", line 1, in <module>
      File "/private/var/folders/vv/w5df7gw55bz_8bry85xf18rh0000gn/T/pip-build-QsLsqM/pygraphviz/setup.py", line 87, in <module>
        tests_require=['nose>=0.10.1', 'doctest-ignore-unicode>=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/

我也试过跑步:

conda install --channel https://conda.anaconda.org/garylschultz pygraphviz

这没有给出任何错误,但 import pygraphviz 在 python 中仍然不起作用。

当我尝试在 python 中导入 pygraphviz 时,出现以下错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/safsafi/anaconda/lib/python2.7/site-packages/pygraphviz/__init__.py", line 54, in <module>
    from agraph import AGraph, Node, Edge, Attribute, ItemAttribute
  File "/Users/safsafi/anaconda/lib/python2.7/site-packages/pygraphviz/agraph.py", line 20, in <module>
    import graphviz as gv
  File "/Users/safsafi/anaconda/lib/python2.7/site-packages/pygraphviz/graphviz.py", line 7, in <module>
    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

提前致谢。

【问题讨论】:

    标签: python python-2.7 anaconda


    【解决方案1】:

    在 Mac OSX 上,我解决了这个问题:

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

    GitHub相关issue

    【讨论】:

      猜你喜欢
      • 2016-01-01
      • 2022-11-22
      • 2015-02-26
      • 2014-11-07
      • 2015-05-22
      • 2014-06-20
      • 1970-01-01
      • 2013-05-05
      • 2016-07-22
      相关资源
      最近更新 更多