如何使用 pip 安装 pygraphviz
Posted
技术标签:
【中文标题】如何使用 pip 安装 pygraphviz【英文标题】:How do I install pygraphviz with pip 【发布时间】:2016-06-09 04:01:51 【问题描述】:这是 brew list 和 pip list
(lebienv) ➜ lebi git:(master) ✗ brew list
graphviz libpng libxml2 mysql openssl
(lebienv) ➜ lebi git:(master) ✗ pip list
Flask (0.10.1)
itsdangerous (0.24)
Jinja2 (2.8)
MarkupSafe (0.23)
pip (8.0.3)
setuptools (20.1.1)
Werkzeug (0.11.4)
wheel (0.29.0)
(lebienv) ➜ lebi git:(master) ✗
并执行pip install pygraphviz
(lebienv) ➜ lebi git:(master) ✗ pip install pygraphviz
Collecting pygraphviz
Using cached pygraphviz-1.3.1.tar.gz
Building wheels for collected packages: pygraphviz
Running setup.py bdist_wheel for pygraphviz ... error
Complete output from command /Users/zyl/song/lebi/lebienv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/5t/965cgdc56ks37w8pmlmw4vx40000gn/T/pip-build-x2Vstw/pygraphviz/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /var/folders/5t/965cgdc56ks37w8pmlmw4vx40000gn/T/tmp7z72M3pip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.11-intel-2.7
creating build/lib.macosx-10.11-intel-2.7/pygraphviz
copying pygraphviz/__init__.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz
copying pygraphviz/agraph.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz
copying pygraphviz/graphviz.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz
copying pygraphviz/release.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz
copying pygraphviz/version.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz
creating build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/__init__.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/test.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/test_attribute_defaults.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/test_attributes.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/test_clear.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/test_drawing.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/test_edge_attributes.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/test_graph.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/test_html.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/test_layout.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/test_node_attributes.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/test_readwrite.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/test_string.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/test_subgraph.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
copying pygraphviz/tests/test_unicode.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
running 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
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.11-intel-2.7/pygraphviz
copying pygraphviz/graphviz_wrap.c -> build/lib.macosx-10.11-intel-2.7/pygraphviz
running build_ext
building 'pygraphviz._graphviz' extension
creating build/temp.macosx-10.11-intel-2.7
creating build/temp.macosx-10.11-intel-2.7/pygraphviz
cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pygraphviz/graphviz_wrap.c -o build/temp.macosx-10.11-intel-2.7/pygraphviz/graphviz_wrap.o
pygraphviz/graphviz_wrap.c:3321:12: warning: incompatible pointer to integer conversion returning 'Agsym_t *' (aka 'struct Agsym_s *') from a function with result type 'int' [-Wint-conversion]
return agattr(g, kind, name, val);
^~~~~~~~~~~~~~~~~~~~~~~~~~
pygraphviz/graphviz_wrap.c:3405:7: warning: unused variable 'fd1' [-Wunused-variable]
int fd1 ;
^
pygraphviz/graphviz_wrap.c:3406:13: warning: unused variable 'mode_obj1' [-Wunused-variable]
PyObject *mode_obj1 ;
^
pygraphviz/graphviz_wrap.c:3407:13: warning: unused variable 'mode_byte_obj1' [-Wunused-variable]
PyObject *mode_byte_obj1 ;
^
pygraphviz/graphviz_wrap.c:3408:9: warning: unused variable 'mode1' [-Wunused-variable]
char *mode1 ;
^
pygraphviz/graphviz_wrap.c:3463:7: warning: unused variable 'fd2' [-Wunused-variable]
int fd2 ;
^
pygraphviz/graphviz_wrap.c:3464:13: warning: unused variable 'mode_obj2' [-Wunused-variable]
PyObject *mode_obj2 ;
^
pygraphviz/graphviz_wrap.c:3465:13: warning: unused variable 'mode_byte_obj2' [-Wunused-variable]
PyObject *mode_byte_obj2 ;
^
pygraphviz/graphviz_wrap.c:3466:9: warning: unused variable 'mode2' [-Wunused-variable]
char *mode2 ;
^
9 warnings generated.
pygraphviz/graphviz_wrap.c:3295:15: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
len = strlen(val);
~ ^~~~~~~~~~~
pygraphviz/graphviz_wrap.c:3321:12: warning: incompatible pointer to integer conversion returning 'Agsym_t *' (aka 'struct Agsym_s *') from a function with result type 'int' [-Wint-conversion]
return agattr(g, kind, name, val);
^~~~~~~~~~~~~~~~~~~~~~~~~~
pygraphviz/graphviz_wrap.c:3313:15: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
len = strlen(val);
~ ^~~~~~~~~~~
pygraphviz/graphviz_wrap.c:3405:7: warning: unused variable 'fd1' [-Wunused-variable]
int fd1 ;
^
pygraphviz/graphviz_wrap.c:3406:13: warning: unused variable 'mode_obj1' [-Wunused-variable]
PyObject *mode_obj1 ;
^
pygraphviz/graphviz_wrap.c:3407:13: warning: unused variable 'mode_byte_obj1' [-Wunused-variable]
PyObject *mode_byte_obj1 ;
^
pygraphviz/graphviz_wrap.c:3408:9: warning: unused variable 'mode1' [-Wunused-variable]
char *mode1 ;
^
pygraphviz/graphviz_wrap.c:3463:7: warning: unused variable 'fd2' [-Wunused-variable]
int fd2 ;
^
pygraphviz/graphviz_wrap.c:3464:13: warning: unused variable 'mode_obj2' [-Wunused-variable]
PyObject *mode_obj2 ;
^
pygraphviz/graphviz_wrap.c:3465:13: warning: unused variable 'mode_byte_obj2' [-Wunused-variable]
PyObject *mode_byte_obj2 ;
^
pygraphviz/graphviz_wrap.c:3466:9: warning: unused variable 'mode2' [-Wunused-variable]
char *mode2 ;
^
11 warnings generated.
cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.11-intel-2.7/pygraphviz/graphviz_wrap.o -lcgraph -lcdt -o build/lib.macosx-10.11-intel-2.7/pygraphviz/_graphviz.so
ld: warning: ignoring file /usr/local/lib/libcdt.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib/libcdt.dylib
ld: warning: ignoring file /usr/local/lib/libcgraph.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib/libcgraph.dylib
installing to build/bdist.macosx-10.11-intel/wheel
running install
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
change the include_dirs and library_dirs variables in setup.py to
point to the correct locations of your graphviz installation.
The current setting of library_dirs and include_dirs is:
library_dirs=None
include_dirs=None
error: Error locating graphviz.
----------------------------------------
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 /Users/zyl/song/lebi/lebienv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/5t/965cgdc56ks37w8pmlmw4vx40000gn/T/pip-build-x2Vstw/pygraphviz/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/5t/965cgdc56ks37w8pmlmw4vx40000gn/T/pip-1imEXi-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/zyl/song/lebi/lebienv/include/site/python2.7/pygraphviz:
running install
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
change the include_dirs and library_dirs variables in setup.py to
point to the correct locations of your graphviz installation.
The current setting of library_dirs and include_dirs is:
library_dirs=None
include_dirs=None
error: Error locating graphviz.
----------------------------------------
Command "/Users/zyl/song/lebi/lebienv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/5t/965cgdc56ks37w8pmlmw4vx40000gn/T/pip-build-x2Vstw/pygraphviz/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/5t/965cgdc56ks37w8pmlmw4vx40000gn/T/pip-1imEXi-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/zyl/song/lebi/lebienv/include/site/python2.7/pygraphviz" failed with error code 1 in /private/var/folders/5t/965cgdc56ks37w8pmlmw4vx40000gn/T/pip-build-x2Vstw/pygraphviz
系统:Mac OS X 版本:10.11.1
如何解决问题。
【问题讨论】:
你应该先安装 Graphviz。 (lebienv) ➜ lebi git:(master) ✗ brew list graphviz 【参考方案1】:按照错误消息中的建议设置 library_dirs
和 include_dirs
对我有用。 This article 显示如何设置它们。但是,首先要确保 pygraphviz
已实际安装。
pip install --install-option="--include-path=/usr/local/include/graphviz/" --install-option="--library-path=/usr/local/lib/graphviz" pygraphviz
【讨论】:
pip install --install-option="--include-path=/usr/local/include/graphviz/" --install-option="--library-path=/usr/local /lib/graphviz" pygraphviz 谢谢@jamjar 您应该将此作为额外答案发布。我节省了大约 10 个小时的尝试时间。【参考方案2】:你试过了吗
pip install git+git://github.com/pygraphviz/pygraphviz.git
正如issue 中所建议的那样?
【讨论】:
以上是关于如何使用 pip 安装 pygraphviz的主要内容,如果未能解决你的问题,请参考以下文章
Pip install pygraphviz 失败:pygraphviz 的构建轮失败
如何在 Windows 10 64 位上安装 pygraphviz
Pygraphviz 安装失败,错误代码 1083 无法打开文件 graphviz/cgraph.h:没有这样的文件或目录