无法安装pygraphviz

时间:2018-11-06 08:10:30

标签: macos pip python-3.6 pygraphviz

我在macOS Mojave 10.14.1上安装pygraphviz时遇到麻烦。我使用的Python版本是3.6.7。 执行命令pip install pygraphviz时,出现以下冗长的错误消息:

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/

有人可以给我帮助吗?谢谢!

我应用了@hoefling的建议:xcode-select --install,然后尝试pip3 install pygraphviz。仍然存在错误,如下图所示: enter image description here

enter image description here

enter image description here

enter image description here

2 个答案:

答案 0 :(得分:1)

问题已通过使用以下命令完成:

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

答案 1 :(得分:0)

在 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