Installing PyGraphViz on Windows, Python 2.7 graphviz-2.36

user2543622 picture user2543622 · Mar 28, 2014 · Viewed 12.4k times · Source

I already referred to link , but still facing issues :(

I successfully installed graphviz on my windows 7. Now i would like to install pygraphviz. I downloaded the pygraphviz zip file and unzipped it. I modified setup.py and added below text.

# Windows
library_path='c:/Program Files (x86)/Graphviz2.36/lib/release/lib'
include_path='C:/Program Files (x86)/Graphviz2.36/include/graphviz'

I also modified unixcompiler.py. I removed the line

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

and instead of it I wrote

compiler = 'gcc'

when i try to install pygraphviz i get below error :(

C:\Users\nnnnnnnnnn\Downloads\pygraphviz-1.2\pygraphviz-1.2>python setup.py install
library_path=c:/Program Files (x86)/Graphviz2.36/lib/release/lib
include_path=C:/Program Files (x86)/Graphviz2.36/include/graphviz
running install
running build
running build_py
running build_ext
building 'pygraphviz._graphviz' extension
C:\strawberry\c\bin\gcc.exe -DMS_WIN64 -mdll -O -Wall "-IC:/Program Files (x86)/
Graphviz2.36/include/graphviz" -IC:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\
include -IC:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\PC -c pygraphviz/graphv
iz_wrap.c -o build\temp.win-amd64-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 wi
thout a cast [enabled by default]
writing build\temp.win-amd64-2.7\Release\pygraphviz\_graphviz.def
Traceback (most recent call last):
  File "setup.py", line 147, in <module>
    package_data     = package_data
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\core.py", l
ine 152, in setup
    dist.run_commands()
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\dist.py", l
ine 953, in run_commands
    self.run_command(cmd)
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\dist.py", l
ine 972, in run_command
    cmd_obj.run()
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\command\ins
tall.py", line 563, in run
    self.run_command('build')
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\cmd.py", li
ne 326, in run_command
    self.distribution.run_command(command)
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\dist.py", l
ine 972, in run_command
    cmd_obj.run()
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\command\bui
ld.py", line 127, in run
    self.run_command(cmd_name)
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\cmd.py", li
ne 326, in run_command
    self.distribution.run_command(command)
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\dist.py", l
ine 972, in run_command
    cmd_obj.run()
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\command\bui
ld_ext.py", line 337, in run
    self.build_extensions()
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\command\bui
ld_ext.py", line 446, in build_extensions
    self.build_extension(ext)
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\command\bui
ld_ext.py", line 528, in build_extension
    target_lang=language)
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\ccompiler.p
y", line 691, in link_shared_object
    extra_preargs, extra_postargs, build_temp, target_lang)
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\cygwinccomp
iler.py", line 260, in link
    target_lang)
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\unixccompil
er.py", line 160, in link
    libraries)
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\ccompiler.p
y", line 1071, in gen_lib_options
    opt = compiler.runtime_library_dir_option(dir)
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\distutils\unixccompil
er.py", line 227, in runtime_library_dir_option
    compiler = os.path.basename(sysconfig.get_config_var("CC"))
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\ntpath.py", line 198,
 in basename
    return split(p)[1]
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\ntpath.py", line 170,
 in split
    d, p = splitdrive(p)
  File "C:\Users\nnnnnnnnnn\AppData\Local\Continuum\Anaconda\lib\ntpath.py", line 125,
 in splitdrive
    if p[1:2] == ':':
TypeError: 'NoneType' object has no attribute '__getitem__'

Answer

Beshr picture Beshr · Oct 27, 2014

An easier solution that works for me:

  • Run pip install graphviz (PS: this step might not be needed)
  • Install Graphviz from: here
  • Install the unofficial binaries for pygraphviz from here
  • Enjoy!