Mac安装pygraphviz 报`#include “graphviz/cgraph.h“`错误

总之,使用brew install graphviz,再执行pip install pygraphviz也报错,错误内容如下:

    Running setup.py install for pygraphviz ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/user/opt/anaconda3/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/mz/qcpvt50n3pjb2vh7mfnckf900000gn/T/pip-install-gzipxcgs/pygraphviz_4fa1b9a5467b47568796340668d99220/setup.py'"'"'; __file__='"'"'/private/var/folders/mz/qcpvt50n3pjb2vh7mfnckf900000gn/T/pip-install-gzipxcgs/pygraphviz_4fa1b9a5467b47568796340668d99220/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' build_ext -I/usr/local/Cellar/graphviz/3.0.0/include -L/usr/local/Cellar/graphviz/3.0.0/lib install --record /private/var/folders/mz/qcpvt50n3pjb2vh7mfnckf900000gn/T/pip-record-yflo6qbu/install-record.txt --single-version-externally-managed --compile --install-headers /Users/user/opt/anaconda3/include/python3.9/pygraphviz
         cwd: /private/var/folders/mz/qcpvt50n3pjb2vh7mfnckf900000gn/T/pip-install-gzipxcgs/pygraphviz_4fa1b9a5467b47568796340668d99220/
    Complete output (11 lines):
    running build_ext
    building 'pygraphviz._graphviz' extension
    creating build
    creating build/temp.macosx-10.9-x86_64-3.9
    creating build/temp.macosx-10.9-x86_64-3.9/pygraphviz
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/user/opt/anaconda3/include -arch x86_64 -I/Users/user/opt/anaconda3/include -fPIC -O2 -isystem /Users/user/opt/anaconda3/include -arch x86_64 -DSWIG_PYTHON_STRICT_BYTE_CHAR -I/usr/local/Cellar/graphviz/3.0.0/include -I/Users/user/opt/anaconda3/include/python3.9 -c pygraphviz/graphviz_wrap.c -o build/temp.macosx-10.9-x86_64-3.9/pygraphviz/graphviz_wrap.o
    pygraphviz/graphviz_wrap.c:2711:10: fatal error: 'graphviz/cgraph.h' file not found
    #include "graphviz/cgraph.h"
             ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    error: command '/usr/bin/clang' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/user/opt/anaconda3/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/mz/qcpvt50n3pjb2vh7mfnckf900000gn/T/pip-install-gzipxcgs/pygraphviz_4fa1b9a5467b47568796340668d99220/setup.py'"'"'; __file__='"'"'/private/var/folders/mz/qcpvt50n3pjb2vh7mfnckf900000gn/T/pip-install-gzipxcgs/pygraphviz_4fa1b9a5467b47568796340668d99220/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' build_ext -I/usr/local/Cellar/graphviz/3.0.0/include -L/usr/local/Cellar/graphviz/3.0.0/lib install --record /private/var/folders/mz/qcpvt50n3pjb2vh7mfnckf900000gn/T/pip-record-yflo6qbu/install-record.txt --single-version-externally-managed --compile --install-headers /Users/user/opt/anaconda3/include/python3.9/pygraphviz Check the logs for full command output.

解决方案:
conda install --channel conda-forge pygraphviz 搞定问题。

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值