我的pygraphviz安装之路
近來(lái),在學(xué)習(xí)python的數(shù)據(jù)挖掘,需要安裝pygraphviz,與諸多麻煩:
注:我的系統(tǒng)是fedora 17beta版;python2.7.3
1、我首先直接安裝pygraphviz(easy_install),提示錯(cuò)誤:
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
2、按照以上錯(cuò)誤提示,我先安裝了Graphviz(yum install graphviz),木牛問(wèn)題;
3、接著再試著安裝libgraphviz-dev,安裝失敗;
4、轉(zhuǎn)而使用pip安裝,出現(xiàn)如下錯(cuò)誤:
Your graphviz installation could not be found.Either the graphviz package is missing on incomplete (binary packages graphviz-dev or graphviz-devel missing?).If you think your installation is correct you will need to manually change the include_path and library_path variables in setup.py to point to the correct locations of your graphviz installation.The current setting of library_path and include_path is: library_path=None include_path=Noneerror: None使用pip安裝和easy_install所不同的是,其在主文件夾中會(huì)出現(xiàn)一個(gè)bulid文件夾,pygraphviz文件被下載緩存在此;
5、于是,修改pygraphviz文件夾中的setup.py文件夾,我使用的是vi;
在其中可以看到:
from glob import glob
import os
import sys
if os.path.exists('MANIFEST'): os.remove('MANIFEST')
?
from distutils.core import setup, Extension
?
from setup_extra import pkg_config, dotneato_config
?
if sys.argv[-1] == 'setup.py':
? ? print "To install, run 'python setup.py install'" //這個(gè)我們接下來(lái)會(huì)用到的;
?
if sys.version_info[:2] < (2, 4):
? ? print "PyGraphviz requires Python version 2.4 or later (%d.%d detected)." % \
? ? ? ? ? sys.version_info[:2]
? ? sys.exit(-1)
?
library_path=None
include_path=None
?上面這兩行需要注釋掉
# If the setup script couldn't find your graphviz installation you can
# specify it here by uncommenting these lines or providing your own:
# You must set both 'library_path' and 'include_path'
?
# Linux, generic UNIX
#library_path='/usr/lib/graphviz'
#include_path='/usr/include/graphviz'
?
# OSX, Linux, alternate location
#library_path='/usr/local/lib/graphviz'
#include_path='/usr/local/include/graphviz'
?上面這兩行需要取消注釋
# OSX (Fink)
#library_path='/sw/lib/graphviz'
#include_path='/sw/include/graphviz'
?
# OSX (MacPorts)
#library_path='/opt/local/lib/graphviz'
#include_path='/opt/local/include/graphviz'
?
# Windows
# Unknown
?
# Attempt to find Graphviz installation
if library_path is None and include_path is None:
? ? print "Trying pkg-config"
? ? include_path,library_path=pkg_config()
?
if library_path is None and include_path is None:
? ? print "Trying dotneato-config"
? ? include_path,library_path=dotneato_config()
?
if library_path is None or include_path is None:
? ? print?
? ? print ?"""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
這個(gè)不就是之前的錯(cuò)誤提示么??
If you think your installation is correct you will need to manually
change the include_path and library_path variables in setup.py to
point to the correct locations of your graphviz installation.
6、按照上述操作進(jìn)行修改,之后運(yùn)行?python setup.py install,但是依然出現(xiàn)錯(cuò)誤:“gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fs………………”?
7、應(yīng)該是gcc包缺失,于是乎,繼續(xù)安裝gcc;使用yum install gcc,出現(xiàn)錯(cuò)誤——一些依賴包無(wú)法安裝;
8、判斷可能是某些包版本不夠新,升級(jí)之(update-testing)
9、升級(jí)完之后,在安裝pygraphviz,出現(xiàn)錯(cuò)誤:“致命錯(cuò)誤,python.h沒(méi)有這個(gè)文件或目錄。”
10、然后,安裝包“python-dev”(yum install python-devel);
11、easy_install 安裝,成功。import?pygraphviz,沒(méi)有報(bào)錯(cuò),OK!
轉(zhuǎn)載于:https://www.cnblogs.com/atricfox/archive/2012/05/12/2497421.html
總結(jié)
以上是生活随笔為你收集整理的我的pygraphviz安装之路的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: SQL Developer更改日期显示格
- 下一篇: 学习jquery选项卡插件