在Windows上安装PyGraphViz,Python 2.7

时间:2011-11-22 09:48:56

标签: python graphviz pygraphviz

我无法在Windows XP上安装pygraphviz。我正在使用Python27。

在启动设置之前,我已经更改了setup.py文件的这两个变量

library_path="C:\\Archivos de programa\\Graphviz 2.28\\bin"
include_path="C:\\Archivos de programa\\Graphviz 2.28\\include\\graphviz"

然后我启动了设置。我正在使用mingw32作为编译器。我不知道我现在能做什么。我正在使用以下命令:

C:\Python27\pygraphviz-1.1>c:\python27\python setup.py build -c mingw32

我得到了结果

library_path=C:\Archivos de programa\Graphviz 2.28\bin
include_path=C:\Archivos de programa\Graphviz 2.28\include\graphviz
running build
running build_py
running build_ext
building 'pygraphviz._graphviz' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall "-IC:\Archivos de programa\Graphviz 2.28\include\graphviz" -Ic:\python27\include -Ic:\python
27\PC -c pygraphviz/graphviz_wrap.c -o build\temp.win32-2.7\Release\pygraphviz\graphviz_wrap.o
pygraphviz/graphviz_wrap.c: In function 'agattr_label':
pygraphviz/graphviz_wrap.c:2855:5: warning: return makes integer from pointer without a cast
writing build\temp.win32-2.7\Release\pygraphviz\_graphviz.def
Traceback (most recent call last):
  File "setup.py", line 146, in <module>
    package_data     = package_data
  File "c:\python27\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "c:\python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "c:\python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "c:\python27\lib\distutils\command\build.py", line 127, in run
    self.run_command(cmd_name)
  File "c:\python27\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "c:\python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "c:\python27\lib\distutils\command\build_ext.py", line 340, in run
    self.build_extensions()
  File "c:\python27\lib\distutils\command\build_ext.py", line 449, in build_extensions
    self.build_extension(ext)
  File "c:\python27\lib\distutils\command\build_ext.py", line 531, in build_extension
    target_lang=language)
  File "c:\python27\lib\distutils\ccompiler.py", line 741, in link_shared_object
    extra_preargs, extra_postargs, build_temp, target_lang)
  File "c:\python27\lib\distutils\cygwinccompiler.py", line 260, in link
    target_lang)
  File "c:\python27\lib\distutils\unixccompiler.py", line 218, in link
    libraries)
  File "c:\python27\lib\distutils\ccompiler.py", line 1121, in gen_lib_options
    opt = compiler.runtime_library_dir_option(dir)
  File "c:\python27\lib\distutils\unixccompiler.py", line 285, in runtime_library_dir_option
    compiler = os.path.basename(sysconfig.get_config_var("CC"))
  File "c:\python27\lib\ntpath.py", line 198, in basename
    return split(p)[1]
  File "c:\python27\lib\ntpath.py", line 170, in split
    d, p = splitdrive(p)
  File "c:\python27\lib\ntpath.py", line 125, in splitdrive
    if p[1:2] == ':':
TypeError: 'NoneType' object is not subscriptable

关于如何通过Windows解决它的任何想法?

在其他使用Ubuntu的计算机上我安装时没有问题。

1 个答案:

答案 0 :(得分:2)

该错误是由于Python distutils库中的错误引起的。编辑你的&#34; C:\ Python27 \ lib \ distutils \ unixccompiler.py&#34;文件(第285行,在runtime_library_dir_option中)并更改

compiler = os.path.basename(sysconfig.get_config_var("CC"))

compiler = 'gcc'

在您设法安装pygraphviz之后,别忘了将其更改回来:)