首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在Python3.6上使用conda或pip安装pygraphviz?

如何在Python3.6上使用conda或pip安装pygraphviz?
EN

Stack Overflow用户
提问于 2018-06-09 07:38:52
回答 2查看 2.6K关注 0票数 1

我不确定在这里要做什么,但我真的需要在networkx中使用graphviz布局。

我是按照安装过程中找不到graphviz的特定方式来做的:

找不到您的Graphviz安装。

1)您没有安装Graphviz :安装Graphviz (http://graphviz.org) 2)您的Graphviz包可能不完整。安装二进制开发子程序包(例如libgraphviz dev或类似的)。3)您使用的是Windows3) Windows没有适用于Windows的PyGraphviz二进制程序包,但您可以从该源代码构建它。查看http://networkx.lanl.gov/pygraphviz/reference/faq.html如果你认为你的安装是正确的,你需要手动提供graphviz include和库的路径。例如: pip install pygraphviz library_dirs和include_dirs的当前设置是: library_dirs=None include_dirs=None error: Error locating graphviz。

以下是我的python版本:

(py3_testing) jespinozlt-osx:~ jespinoz$ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

这是我Mac上的OS版本

(py3_testing) jespinozlt-osx:~ jespinoz$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.11.6
BuildVersion:   15G1217

我确保安装了graphviz

(py3_testing) jespinozlt-osx:~ jespinoz$ ls -l ~/anaconda/envs/py3_testing/include/| grep "graphviz"
drwxr-xr-x   29 jespinoz  tigr     986 Jun  6 12:51 graphviz
(py3_testing) jespinozlt-osx:~ jespinoz$ ls -l ~/anaconda/envs/py3_testing/lib/| grep "graphviz"
drwxr-xr-x   18 jespinoz  tigr       612 Jun  6 12:51 graphviz

现在,当我尝试通过pip进行安装时

(py3_testing) jespinozlt-osx:~ jespinoz$ pip install pygraphviz --install-option="--include-path=~/anaconda/envs/py3_testing/include/graphviz/" --install-option="--library-path=~/anaconda/envs/py3_testing/lib/graphviz"
/Users/jespinoz/anaconda/envs/py3_testing/lib/python3.6/site-packages/pip/commands/install.py:194: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
  cmdoptions.check_install_build_global(options)
Collecting pygraphviz
  Using cached https://files.pythonhosted.org/packages/98/bb/a32e33f7665b921c926209305dde66fe41003a4ad934b10efb7c1211a419/pygraphviz-1.3.1.tar.gz
Skipping bdist_wheel for pygraphviz, due to binaries being disabled for it.
Installing collected packages: pygraphviz
  Running setup.py install for pygraphviz ... error
    Complete output from command /Users/jespinoz/anaconda/envs/py3_testing/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/6z/5vbtz_gmkr76ftgc3149dvtr0003c0/T/pip-build-_hho1hi2/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 /var/folders/6z/5vbtz_gmkr76ftgc3149dvtr0003c0/T/pip-v2gpw_h3-record/install-record.txt --single-version-externally-managed --compile --include-path=~/anaconda/envs/py3_testing/include/graphviz/ --library-path=~/anaconda/envs/py3_testing/lib/graphviz:
    running install
    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/__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
    copying pygraphviz/graphviz.py -> 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
    creating 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.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_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_drawing.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_graph.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_layout.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_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/test_subgraph.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
    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 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
    x86_64-apple-darwin13.4.0-clang -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9 -I~/anaconda/envs/py3_testing/include/graphviz/ -I/Users/jespinoz/anaconda/envs/py3_testing/include/python3.6m -c pygraphviz/graphviz_wrap.c -o build/temp.macosx-10.9-x86_64-3.6/pygraphviz/graphviz_wrap.o
    pygraphviz/graphviz_wrap.c:2954:10: fatal error: 'graphviz/cgraph.h' file not found
    #include "graphviz/cgraph.h"
             ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    error: command 'x86_64-apple-darwin13.4.0-clang' failed with exit status 1

    ----------------------------------------
Command "/Users/jespinoz/anaconda/envs/py3_testing/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/6z/5vbtz_gmkr76ftgc3149dvtr0003c0/T/pip-build-_hho1hi2/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 /var/folders/6z/5vbtz_gmkr76ftgc3149dvtr0003c0/T/pip-v2gpw_h3-record/install-record.txt --single-version-externally-managed --compile --include-path=~/anaconda/envs/py3_testing/include/graphviz/ --library-path=~/anaconda/envs/py3_testing/lib/graphviz" failed with error code 1 in /private/var/folders/6z/5vbtz_gmkr76ftgc3149dvtr0003c0/T/pip-build-_hho1hi2/pygraphviz/

我用Homebrew安装的:

(python3) jespinozlt-osx:anaconda jespinoz$ ls /usr/local/Cellar/graphviz/2.40.1/include/graphviz/
(python3) jespinozlt-osx:anaconda jespinoz$ ls /usr/local/Cellar/graphviz/2.40.1/lib/
graphviz/             libcdt.dylib          libcgraph.dylib       libgvc.dylib          libgvpr.dylib         liblab_gamut.dylib    libpathplan.dylib     libxdot.dylib
libcdt.5.dylib        libcgraph.6.dylib     libgvc.6.dylib        libgvpr.2.dylib       liblab_gamut.1.dylib  libpathplan.4.dylib   libxdot.4.dylib       pkgconfig/
(python3) jespinozlt-osx:anaconda jespinoz$ ls /usr/local/Cellar/graphviz/2.40.1/lib/graphviz/
config6                 libgvplugin_core.dylib          libgvplugin_dot_layout.dylib        libgvplugin_gd.dylib            libgvplugin_neato_layout.dylib      libgvplugin_quartz.dylib
libgvplugin_core.6.dylib        libgvplugin_dot_layout.6.dylib      libgvplugin_gd.6.dylib          libgvplugin_neato_layout.6.dylib    libgvplugin_quartz.6.dylib      tcl
(python3) jespinozlt-osx:anaconda jespinoz$ pip install pygraphviz --install-option="--include-path=/usr/local/Cellar/graphviz/2.40.1/include/graphviz/" --install-option="--library-path=/usr/local/Cellar/graphviz/2.40.1/lib/graphviz"
/Users/jespinoz/anaconda/envs/python3/lib/python3.6/site-packages/pip/_internal/commands/install.py:199: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
  cmdoptions.check_install_build_global(options)
Collecting pygraphviz
  Using cached https://files.pythonhosted.org/packages/98/bb/a32e33f7665b921c926209305dde66fe41003a4ad934b10efb7c1211a419/pygraphviz-1.3.1.tar.gz
Skipping bdist_wheel for pygraphviz, due to binaries being disabled for it.
mxnet 1.1.0 has requirement numpy<=1.13.3, but you'll have numpy 1.14.2 which is incompatible.
Installing collected packages: pygraphviz
  Running setup.py install for pygraphviz ... error
    Complete output from command /Users/jespinoz/anaconda/envs/python3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/6z/5vbtz_gmkr76ftgc3149dvtr0003c0/T/pip-install-2d1lydtv/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/6z/5vbtz_gmkr76ftgc3149dvtr0003c0/T/pip-record-adm5qrum/install-record.txt --single-version-externally-managed --compile --include-path=/usr/local/Cellar/graphviz/2.40.1/include/graphviz/ --library-path=/usr/local/Cellar/graphviz/2.40.1/lib/graphviz:
    running install
    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/__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
    copying pygraphviz/graphviz.py -> 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
    creating 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.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_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_drawing.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_graph.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_layout.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_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/test_subgraph.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
    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 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
    x86_64-apple-darwin13.4.0-clang -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9 -I/usr/local/Cellar/graphviz/2.40.1/include/graphviz/ -I/Users/jespinoz/anaconda/envs/python3/include/python3.6m -c pygraphviz/graphviz_wrap.c -o build/temp.macosx-10.9-x86_64-3.6/pygraphviz/graphviz_wrap.o
    pygraphviz/graphviz_wrap.c:2954:10: fatal error: 'graphviz/cgraph.h' file not found
    #include "graphviz/cgraph.h"
             ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    error: command 'x86_64-apple-darwin13.4.0-clang' failed with exit status 1

    ----------------------------------------
Command "/Users/jespinoz/anaconda/envs/python3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/6z/5vbtz_gmkr76ftgc3149dvtr0003c0/T/pip-install-2d1lydtv/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/6z/5vbtz_gmkr76ftgc3149dvtr0003c0/T/pip-record-adm5qrum/install-record.txt --single-version-externally-managed --compile --include-path=/usr/local/Cellar/graphviz/2.40.1/include/graphviz/ --library-path=/usr/local/Cellar/graphviz/2.40.1/lib/graphviz" failed with error code 1 in /private/var/folders/6z/5vbtz_gmkr76ftgc3149dvtr0003c0/T/pip-install-2d1lydtv/pygraphviz/
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-07-11 02:34:07

终于让它工作起来了:

# PyGraphViz
conda install graphviz --yes
pip download git+git://github.com/pygraphviz/pygraphviz.git#egg=pygraphviz
unzip pygraphviz*.zip
cd pygraphviz
python setup.py install --include-path=$CONDA_PREFIX/include --library-path=$CONDA_PREFIX/lib
pip install pydot
票数 1
EN

Stack Overflow用户

发布于 2018-06-09 07:45:51

使用以下命令行(您需要homebrew):

brew install graphviz
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50769629

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档