【问题标题】:PyGraphviz is just not getting installed in OS-X 10.9.4PyGraphviz 只是没有安装在 OS-X 10.9.4 中
【发布时间】:2016-07-07 00:06:15
【问题描述】:

注意:以下任何帖子均未涉及此问题:123

目的是安装 PyGraphviz 以使用 python-weka-wrapper 提供的可视化工具。我只是无法安装 PyGraphviz。以下是我从pip尝试时遇到的错误

$ sudo pip install git+git://github.com/pygraphviz/pygraphviz.git
Password:
The directory '/Users/Ebe/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/Ebe/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting git+git://github.com/pygraphviz/pygraphviz.git
  Cloning git://github.com/pygraphviz/pygraphviz.git to /tmp/pip-rMp2aK-build
Installing collected packages: pygraphviz
  Running setup.py install for pygraphviz ... error
    Complete output from command /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/tmp/pip-rMp2aK-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-CrnqPI-record/install-record.txt --single-version-externally-managed --compile:
    /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools/dist.py:282: UserWarning: Normalizing '1.4.dev' to '1.4.dev0'
      normalized_version,
    running install
    Trying pkg-config
    include_dirs=/opt/local/include/graphviz
    library_dirs=/opt/local/lib
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.9-x86_64-2.7
    creating build/lib.macosx-10.9-x86_64-2.7/pygraphviz
    copying pygraphviz/__init__.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz
    copying pygraphviz/agraph.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz
    copying pygraphviz/graphviz.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz
    copying pygraphviz/release.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz
    copying pygraphviz/version.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz
    creating build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/__init__.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/test.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/test_attribute_defaults.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/test_attributes.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/test_clear.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/test_drawing.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/test_edge_attributes.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/test_graph.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/test_html.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/test_layout.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/test_node_attributes.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/test_readwrite.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/test_string.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/test_subgraph.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    copying pygraphviz/tests/test_unicode.py -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz/tests
    running egg_info
    creating pygraphviz.egg-info
    writing pygraphviz.egg-info/PKG-INFO
    writing top-level names to pygraphviz.egg-info/top_level.txt
    writing dependency_links to pygraphviz.egg-info/dependency_links.txt
    writing manifest file 'pygraphviz.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'pygraphviz.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    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-2.7/pygraphviz
    copying pygraphviz/graphviz_wrap.c -> build/lib.macosx-10.9-x86_64-2.7/pygraphviz
    running build_ext
    building 'pygraphviz._graphviz' extension
    creating build/temp.macosx-10.9-x86_64-2.7
    creating build/temp.macosx-10.9-x86_64-2.7/pygraphviz
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -pipe -Os -fwrapv -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/include/graphviz -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pygraphviz/graphviz_wrap.c -o build/temp.macosx-10.9-x86_64-2.7/pygraphviz/graphviz_wrap.o
    pygraphviz/graphviz_wrap.c:2987:10: fatal error: 'graphviz/cgraph.h' file not found
    #include "graphviz/cgraph.h"
             ^
    1 error generated.
    error: command '/usr/bin/clang' failed with exit status 1

    ----------------------------------------
Command "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/tmp/pip-rMp2aK-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-CrnqPI-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-rMp2aK-build/

Graphviz 是在 MacPorts 的帮助下安装的。在上面的结果中,它的路径是明确的

include_dirs=/opt/local/include/graphviz
library_dirs=/opt/local/lib

graphviz/cgraph.h 也存在。那么安装出了什么问题。

我在网上尝试了所有方法,但似乎没有任何效果。这是我尝试过的完整列表。

  • 从 git 安装:

    sudo pip install git+git://github.com/pygraphviz/pygraphviz.git

  • 从包源的 setup.py 安装:

    sudo python setup.py install

  • 使用包含和库路径沿着 win 命令行安装:

    sudo python setup.py install --include-path=/opt/local/include/graphviz --library-path=/opt/local/lib/graphviz

每一个都抛出相同的错误。

我该怎么办?

【问题讨论】:

  • 你是怎么解决这个问题的?我已经尝试了所有这些选项,但没有任何效果?

标签: python macos installation package pygraphviz


【解决方案1】:

尝试改用:include_dirs=/opt/local/include

【讨论】:

  • 这将受益于显示实际的命令行。是否带有include_dirs=xxx pip install ...,即临时环境变量?是--include_dirs 标志吗?谁知道?
【解决方案2】:

这对我来说很好用:

pip install --global-option=build_ext --global-option="-I/opt/local/include/" --global-option="-L/opt/local/lib" PyGraphviz

参考:python pip specify a library directory and an include directory

【讨论】:

  • 也为我工作。直接开箱即用,无需大惊小怪。请记住,OP 在 macports 上,因此 Brew 看起来会有所不同,即可能是 /usr/local
【解决方案3】:

这对我来说很好用:

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

参考:PyGraphvizをmacOSにインストールする

【讨论】:

  • 这看起来像是基于 Brew 的安装,而 OP 询问的是 macports。请注意 /usr/local/opt/local 的不同之处。路径。如果您使用 Brew,可能会起作用,但 whitecoffee 与端口相关的答案对我有用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-03
  • 2014-11-07
  • 2022-11-22
  • 2014-11-07
相关资源
最近更新 更多