21

Anybody out there has successfully installed PygraphViz on Windows?

Since there is not an official release for Windows, I'm trying to build it myself, but it fails to compile. I'm not the first one to face this issue, but I could not find an answer.

This is the console output:

C:\Python26\Lib\site-packages\pygraphviz-0.99.1>c:\python26\python.exe setup.py
install
library_path=C:/Program Files/Graphviz2.26.3/lib/debug/dll
include_path=C:/Program Files/Graphviz2.26.3/include/graphviz
running install
running build
running build_py
running build_ext
building 'pygraphviz._graphviz' extension
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W
3 /GS- /DNDEBUG "-IC:/Program Files/Graphviz2.26.3/include/graphviz" -Ic:\python
26\include -Ic:\python26\PC /Tcpygraphviz/graphviz_wrap.c /Fobuild\temp.win32-2.
6\Release\pygraphviz/graphviz_wrap.obj
graphviz_wrap.c
warning: I don't know what to do with 'runtime_library_dirs': ['C:/Program Files
/Graphviz2.26.3/lib/debug/dll']
error: don't know how to set runtime library search path for MSVC++

Any help would be appreciated!

jbochi
  • 28,816
  • 16
  • 73
  • 90
  • I have the exact same problem. Python2.6 on Windows Server 2008 R2 with PygraphViz 0.99.1 and graphviz 2.26.3. Any ideas... anyone? – inspectorG4dget May 24 '10 at 23:24

8 Answers8

18

I appreciate this may be an obsolete thread by now, but to update it for others currently hitting this wall, the installer at Christoph Gohlke's Unofficial Windows Binaries for Python Extension Packages has just worked for me..

geotheory
  • 22,624
  • 29
  • 119
  • 196
4

I've just ran into the same problem myself today. It isn't much of an answer, but I read in their FAQ:

Q:

How do I compile pygraphviz under Windows? And why don’t you distribute a pygraphviz Windows installer?

A:

We don’t have Windows development machines but would like to have pygraphviz work on all platforms. If you have success with Windows or would be willing to help test and distribute a Windows installer please drop us a note.

See also ticket 67: https://networkx.lanl.gov/ticket/67

This, together with multiple unanswered pleas for help on various forums, mailing lists and newsgroups, lead me to believe that running PyGraphviz on Windows isn't something that can be done simply today.

So I did the next obvious thing (*) and fired up my Ubuntu on top of VirtualBox to create Graphviz graphs with Python. Curiously, it fails to install from source on Ubuntu as well, unless you have Graphviz itself installed from source, but it can be installed from a pre-built package with sudo apt-get python-pygraphviz.

So now I'm a happy pygraphviz user. Or at least 90% happy. PGV shows a os.popen3 deprecation warning on Python 2.6, and a 18-month-old ticket with a patch on this issue still hasn't been incorporated. Argh!

(*) I do it more and more lately...

Community
  • 1
  • 1
Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
  • 2
    Actually you are looking at the fixed code at https://networkx.lanl.gov/trac/changeset/1073/pygraphviz/trunk/pygraphviz/agraph.py Apparently the version of pygraphviz you installed is older than that fix. You can get the latest version at /http://networkx.lanl.gov/download/pygraphviz/ – Aric Nov 20 '10 at 21:56
4

Here's what worked for me in Python 2.7. I assume it should work similarly in Python 2.6. Precondition: Install mingw32 (included in pythonxy distrib if you're using it), Graphviz

1) Download pygraphviz sources

2) Edit setup.py to change paths to smth like

library_path=r"c:\Program Files (x86)\Graphviz 2.28\bin"
include_path=r"c:\Program Files (x86)\Graphviz 2.28\include\graphviz"

Note that it's \bin, not \lib. Linking with libs didn't work for me.

3) run python setup.py build -c mingw32

Result of step 3:

c:\Python27\Lib\site-packages\pygraphviz-1.1>python setup.py build -c mingw32
library_path=c:\Program Files (x86)\Graphviz 2.28\bin
include_path=c:\Program Files (x86)\Graphviz 2.28\include\graphviz
running build
running build_py
running build_ext
building 'pygraphviz._graphviz' extension
C:\MinGW32-xy\bin\gcc.exe -mno-cygwin -mdll -O -Wall "-Ic:\Program Files (x86)\G
raphviz 2.28\include\graphviz" -Ic:\Python27\include -Ic:\Python27\PC -c pygraph
viz/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 wi
thout a cast
writing build\temp.win32-2.7\Release\pygraphviz\_graphviz.def
C:\MinGW32-xy\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.7\Release\py
graphviz\graphviz_wrap.o build\temp.win32-2.7\Release\pygraphviz\_graphviz.def "
-Lc:\Program Files (x86)\Graphviz 2.28\bin" -Lc:\Python27\libs -Lc:\Python27\PCb
uild "-Wl,-Rc:\Program Files (x86)\Graphviz 2.28\bin" -lcgraph -lcdt -lpython27
-lmsvcr90 -o build\lib.win32-2.7\pygraphviz\_graphviz.pyd

4) copy the result from the just built lib.win32-2.7 (single sub-folder called pygraphviz) into your Python's site-packages folder

Enjoy!

Andrew Filev
  • 106
  • 1
  • 2
  • How did you installed MinGW32-xy? I am using MinGW Minimalist GNU for Windows and I have problems with it. When I try to install pygraphviz I get this error: cc1.exe: error: unrecognized command line option '-mno-cygwin'. – Seitaridis Nov 25 '11 at 08:49
  • I don't remember, but I think it was part of the pythonxy distro. – Andrew Filev Dec 01 '11 at 20:06
  • 3
    mingw32 with gcc 4.6.x wont work with Python 2.7.2 distutils due to the missing -mno-cygwin. It is a known Python core issue. ptyhonxy ships with 4.5.x still. – Gabi Davar Jan 01 '12 at 13:16
  • @Ηλίας, you unzip the source code, and it is just in the folder – xiao 啸 Jul 27 '12 at 07:25
1

If you remove the 'runtime_library_dirs' parameter from the extension dictionary in on line 147 in setup.py, your error message goes away. However, it can't find cgraph.lib. If you change your settings to

library_path=r'C:\Program Files\Graphviz2.26.3\lib\debug\lib'

everything complies and installs. You can import the modules, but the moment you try and access anything, it bombs out. In looking at the source for GraphViz, it appears that the windows version is C#/.NET - perhaps that is the source of our problems?

WombatPM
  • 2,561
  • 2
  • 22
  • 22
1

Hat the same problem and I finally got it to work! The problem was actually in Python's msvc9compiler.py (yes you do need VS8's vc9 to compile, too). The error comes on line 698 in the function runtime_library_dir_option(). Instead of having it throw an error, have it return the same string as library_dir_option():

def runtime_library_dir_option(self, dir):
    return "/LIBPATH:" + dir

Then compile and it should work.

0

I managed to compile pygraphviz under windows with the following setup:

Windows 7, WinPython-32bit-2.7.6.3, Graphviz2.38, microsoft visual c++ 2008 express edition, pygraphvize 1.3 dev

in setup.py changed lines 35 and 36 to:

include_dirs = r"C:\Program Files\Graphviz2.38\include" library_dirs = r"C:\Program Files\Graphviz2.38\lib\release\lib"

The compilation works and you get a working pygraphviz python module.

Hopes this helps.

jur
  • 514
  • 5
  • 5
0

This works for me, Python 2.7 32 bit, PyGraphViz 2.38, VCForPython27, Windows 10 64 bit.

First, install VCForPython27, see http://aka.ms/vcpython27.

Then, execute the following command, so that distutils.msvc9compiler can find the VC compiler. (This needs Administrator privilege. And if your Windows is 32 bit, you need to adjust the registry key.)

reg add HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\9.0\Setup\VC -v productdir -t REG_SZ -d "%LocalAppData%\Programs\Common\Microsoft\Visual C++ for Python\9.0" -f

Finally, install PyGraphViz.

set INCLUDE=C:\Program Files (x86)\Graphviz2.38\include
set LIB=C:\Program Files (x86)\Graphviz2.38\lib\release\lib
pip install pygraphviz
0

Alternately, you can try to use easy_install and avoid compiling. I installed "distribute", a fork of easy_install. But it also requires pkg-config, and you either have to compile that or get an older version. Furthermore, you also have to add pkg-config to the application path.

scvalex
  • 14,931
  • 2
  • 34
  • 43
jdgjdg
  • 1
  • 1
    This only works if they supply an easy_install-able version for windows, which it sounds like they don't. Although this post is from May... – Falmarri Dec 17 '10 at 00:34