【问题标题】:Errors installing pygraphviz on mac os 11.6在 mac os 11.6 上安装 pygraphviz 时出错
【发布时间】:2022-11-22 04:20:09
【问题描述】:

我正在尝试安装 pygraphviz 以便为我的网络获取布局。但是,我在使用 pip install pygraphviz 安装 pygraphviz 时遇到了问题。我收到以下冗长的错误:

ERROR: Command errored out with exit status 1:
   command: /opt/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/w0/pv1mwphj1t552sml25d44bq40000gn/T/pip-install-dabvxss7/pygraphviz/setup.py'"'"'; __file__='"'"'/private/var/folders/w0/pv1mwphj1t552sml25d44bq40000gn/T/pip-install-dabvxss7/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/w0/pv1mwphj1t552sml25d44bq40000gn/T/pip-wheel-ktbtqll_
       cwd: /private/var/folders/w0/pv1mwphj1t552sml25d44bq40000gn/T/pip-install-dabvxss7/pygraphviz/
  Complete output (71 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-3.8
  creating build/lib.macosx-10.9-x86_64-3.8/pygraphviz
  copying pygraphviz/scraper.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz
  copying pygraphviz/graphviz.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz
  copying pygraphviz/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz
  copying pygraphviz/agraph.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz
  copying pygraphviz/testing.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz
  creating build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/test_unicode.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/test_scraper.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/test_readwrite.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/test_string.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/test_html.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/test_node_attributes.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/test_drawing.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/test_subgraph.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/test_close.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/test_edge_attributes.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/test_clear.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/test_layout.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/test_attribute_defaults.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
  copying pygraphviz/tests/test_graph.py -> build/lib.macosx-10.9-x86_64-3.8/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 '*.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.8/pygraphviz
  copying pygraphviz/graphviz_wrap.c -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz
  running build_ext
  building 'pygraphviz._graphviz' extension
  creating build/temp.macosx-10.9-x86_64-3.8
  creating build/temp.macosx-10.9-x86_64-3.8/pygraphviz
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/anaconda3/include -arch x86_64 -I/opt/anaconda3/include -arch x86_64 -I/opt/anaconda3/include/python3.8 -c pygraphviz/graphviz_wrap.c -o build/temp.macosx-10.9-x86_64-3.8/pygraphviz/graphviz_wrap.o
  pygraphviz/graphviz_wrap.c:1756:7: warning: 'tp_print' is deprecated [-Wdeprecated-declarations]
        0,                                    /* tp_print */
        ^
  /opt/anaconda3/include/python3.8/cpython/object.h:260:5: note: 'tp_print' has been explicitly marked deprecated here
      Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
      ^
  /opt/anaconda3/include/python3.8/pyport.h:515:54: note: expanded from macro 'Py_DEPRECATED'
  #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                       ^
  pygraphviz/graphviz_wrap.c:1923:7: warning: 'tp_print' is deprecated [-Wdeprecated-declarations]
        0,                                    /* tp_print */
        ^
  /opt/anaconda3/include/python3.8/cpython/object.h:260:5: note: 'tp_print' has been explicitly marked deprecated here
      Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
      ^
  /opt/anaconda3/include/python3.8/pyport.h:515:54: note: expanded from macro 'Py_DEPRECATED'
  #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                       ^
  pygraphviz/graphviz_wrap.c:2711:10: fatal error: 'graphviz/cgraph.h' file not found
  #include "graphviz/cgraph.h"
           ^~~~~~~~~~~~~~~~~~~
  2 warnings and 1 error generated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: 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
    ERROR: Command errored out with exit status 1:
     command: /opt/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/w0/pv1mwphj1t552sml25d44bq40000gn/T/pip-install-dabvxss7/pygraphviz/setup.py'"'"'; __file__='"'"'/private/var/folders/w0/pv1mwphj1t552sml25d44bq40000gn/T/pip-install-dabvxss7/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/w0/pv1mwphj1t552sml25d44bq40000gn/T/pip-record-p4ku8efv/install-record.txt --single-version-externally-managed --compile --install-headers /opt/anaconda3/include/python3.8/pygraphviz
         cwd: /private/var/folders/w0/pv1mwphj1t552sml25d44bq40000gn/T/pip-install-dabvxss7/pygraphviz/
    Complete output (71 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.9-x86_64-3.8
    creating build/lib.macosx-10.9-x86_64-3.8/pygraphviz
    copying pygraphviz/scraper.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz
    copying pygraphviz/graphviz.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz
    copying pygraphviz/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz
    copying pygraphviz/agraph.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz
    copying pygraphviz/testing.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz
    creating build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/test_unicode.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/test_scraper.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/test_readwrite.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/test_string.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/test_html.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/test_node_attributes.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/test_drawing.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/test_subgraph.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/test_close.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/test_edge_attributes.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/test_clear.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/test_layout.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/test_attribute_defaults.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests
    copying pygraphviz/tests/test_graph.py -> build/lib.macosx-10.9-x86_64-3.8/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 '*.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.8/pygraphviz
    copying pygraphviz/graphviz_wrap.c -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz
    running build_ext
    building 'pygraphviz._graphviz' extension
    creating build/temp.macosx-10.9-x86_64-3.8
    creating build/temp.macosx-10.9-x86_64-3.8/pygraphviz
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/anaconda3/include -arch x86_64 -I/opt/anaconda3/include -arch x86_64 -I/opt/anaconda3/include/python3.8 -c pygraphviz/graphviz_wrap.c -o build/temp.macosx-10.9-x86_64-3.8/pygraphviz/graphviz_wrap.o
    pygraphviz/graphviz_wrap.c:1756:7: warning: 'tp_print' is deprecated [-Wdeprecated-declarations]
          0,                                    /* tp_print */
          ^
    /opt/anaconda3/include/python3.8/cpython/object.h:260:5: note: 'tp_print' has been explicitly marked deprecated here
        Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
        ^
    /opt/anaconda3/include/python3.8/pyport.h:515:54: note: expanded from macro 'Py_DEPRECATED'
    #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                         ^
    pygraphviz/graphviz_wrap.c:1923:7: warning: 'tp_print' is deprecated [-Wdeprecated-declarations]
          0,                                    /* tp_print */
          ^
    /opt/anaconda3/include/python3.8/cpython/object.h:260:5: note: 'tp_print' has been explicitly marked deprecated here
        Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
        ^
    /opt/anaconda3/include/python3.8/pyport.h:515:54: note: expanded from macro 'Py_DEPRECATED'
    #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                         ^
    pygraphviz/graphviz_wrap.c:2711:10: fatal error: 'graphviz/cgraph.h' file not found
    #include "graphviz/cgraph.h"
             ^~~~~~~~~~~~~~~~~~~
    2 warnings and 1 error generated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /opt/anaconda3/bin/python -u -c

有谁知道如何解决这个问题。我经历了很多堆栈溢出线程,但没有任何效果。感谢您的建议!

【问题讨论】:

    标签: python


    【解决方案1】:

    PyGraphviz 需要安装 graphviz 库。执行此操作的最简单方法可能是使用 homebrew,如 PyGraphviz installation docs 的 macOS 部分所述。

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题,但是直接建议无法正常工作。 因此,顺序如下:

      1. brew install graphviz
      2. pip install --install-option="--include-path=/opt/local/include" --install-option="--library-path=/opt/local/lib" pygraphviz

        第二个——是如何在 brew install 之后强制pip 找到头文件的正确路径。

      【讨论】:

        猜你喜欢
        • 2016-01-01
        • 2014-11-07
        • 1970-01-01
        • 2021-11-12
        • 2014-12-03
        • 2018-09-22
        • 2015-12-10
        • 2016-02-18
        • 2011-05-16
        相关资源
        最近更新 更多