Ropardo Sowftware development company

Experience software development with ROPARDO S.R.L.

RSS Feed
RSS Feed
  • Home
  • About ROPARDO S.R.L
  • Our websites

Installing PyGraphviz on Windows

Django Extensions provides a bunch of management commands for the Django Framework. One of the most handy is the graph_models command. This command creates a visual representation of the Django models existing in the database.

In order to use this command you need to have Graphviz and PyGraphviz installed on your machine. Graphviz is a package of open-source tools for representing structural information as diagrams of abstract graphs and networks. PyGraphviz is a Python interface for Graphviz and allows you can create, edit, read, write, and draw Graphviz graphs.

Download and install Graphviz from this link: http://www.graphviz.org/Download_windows.php.

I couldn’t install PyGraphviz using easy_install, because it depends on Graphviz, and easy_install doesn’t know where to find Graphviz.

Download PyGraphviz(1.1) from this link: http://networkx.lanl.gov/download/pygraphviz/, and extract it.

Adjust “setup.py” file to reflect your Graphviz instalation.


library_path='C:/Program Files (x86)/Graphviz 2.28/lib/release/lib'
include_path='C:/Program Files (x86)/Graphviz 2.28/include/graphviz'

Normally, you would run python setup.py install to build and install a python application, but in this case we need to do some extra work. Running this command will output an error:


"Unable to find vcvarsall.bat"

To solve this issue, PyGraphviz needs to be compiled with a MSVC or mingw32 compiler. I haven’t found a Windows build for PyGraphviz so the only option was to built this myself.

I have used an older release of mingw because the current one doesn’t support the mno-cygwin argument anymore.

Download and install mingw-get-inst-20100831.exe from this link:
http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/

Add mingw/bin directory to the system path.

Change line 285 from “c:\python27\lib\distutils\unixcompiler.py” from

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

to

1
compiler = "gcc".

or there will be an error “TypeError: ‘NoneType’ object is unsubscriptable”. Change it back after finishing installing PyGraphviz.

Now it’s time to build PyGraphviz:

C:\pygraphviz-1.1>python setup.py build -c mingw32
library_path=C:/Graphviz/lib/release/lib
include_path=C:/Graphviz/include/graphviz
running build
running build_py
creating build
creating build\lib.win32-2.7
creating build\lib.win32-2.7\pygraphviz
copying pygraphviz\agraph.py -> build\lib.win32-2.7\pygraphviz
copying pygraphviz\graphviz.py -> build\lib.win32-2.7\pygraphviz
copying pygraphviz\release.py -> build\lib.win32-2.7\pygraphviz
copying pygraphviz\version.py -> build\lib.win32-2.7\pygraphviz
copying pygraphviz\__init__.py -> build\lib.win32-2.7\pygraphviz
creating build\lib.win32-2.7\pygraphviz\tests
copying pygraphviz\tests\test.py -> build\lib.win32-2.7\pygraphviz\tests
copying pygraphviz\tests\__init__.py -> build\lib.win32-2.7\pygraphviz\tests
copying pygraphviz\tests\attributes.txt -> build\lib.win32-2.7\pygraphviz\tests
copying pygraphviz\tests\graph.txt -> build\lib.win32-2.7\pygraphviz\tests
copying pygraphviz\tests\layout_draw.txt -> build\lib.win32-2.7\pygraphviz\tests
copying pygraphviz\tests\unicode.txt -> build\lib.win32-2.7\pygraphviz\tests
running build_ext
building 'pygraphviz._graphviz' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
creating build\temp.win32-2.7\Release\pygraphviz
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:/Graphviz/include/graphviz -
IC:\Python27\include -IC:\Python27\PC -c pygraphviz/graphviz_wrap.c -o build\tem
p.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:\MinGW\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.7\Release\pygraph
viz\graphviz_wrap.o build\temp.win32-2.7\Release\pygraphviz\_graphviz.def -LC:/G
raphviz/lib/release/lib -LC:\Python27\libs -LC:\Python27\PCbuild -Wl,-RC:/Graphv
iz/lib/release/lib -lcgraph -lcdt -lpython27 -lmsvcr90 -o build\lib.win32-2.7\py
graphviz\_graphviz.pyd

Copy the contents of the build/lib.win32-2.7 directory(single sub-folder called pygraphviz) into your Python’s site-packages folder.

You can create a PNG image file called my_project_visualized.png with application grouping running the following command:

manage.py graph_models -a -g -o my_project_visualized.png

Django Extensions
Graphviz website
PyGraphviz website
Minimalist GNU for Windows

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Get Shareaholic
Tags: django extension how to Python Windows

 Posted in: Java
November 28, 2011 | Ioan Seicean | One Comment

One Response

  • sushant
    January 21, 2012
    1

    I did what you have said above but it gives error as:
    “error: command ‘gcc’ failed no such file or directory”

Leave a Reply

 


  • « Previous post
  • Next post »
  • Recent Posts

    • Meet Ropardo at CeBit 2012
    • Installing PyGraphviz on Windows
    • Convert python object to XML representation
    • Liferay Portlet Development
    • Norway Road Show 2011 private meeting invitation
  • Ropardo is Hiring

  • Subscribe

    • Add to Google Reader or Homepage Add to netvibes TopOfBlogs
  • Recent Comments

    • ze_felipe on GWT 2.1 – Uploading a file using the RPC mechanism
    • Artiom on GWT 2.1 – Uploading a file using the RPC mechanism
    • sushant on Installing PyGraphviz on Windows
    • Luis Molina on Connect to an Axis 1 Web Service with Basic Authentication
    • R.Ganesan on Multiple select TreeView in ComboBox
  • Archives

    • February 2012 (1)
    • November 2011 (1)
    • September 2011 (4)
    • July 2011 (3)
    • June 2011 (2)
    • May 2011 (4)
    • April 2011 (4)
    • March 2011 (3)
    • February 2011 (2)
    • January 2011 (2)
    • December 2010 (1)
    • November 2010 (4)
    • October 2010 (4)
    • August 2010 (3)
    • July 2010 (3)
    • June 2010 (6)
    • May 2010 (8)
    • April 2010 (7)
    • March 2010 (9)
    • February 2010 (6)
    • January 2010 (5)
    • December 2009 (7)
    • November 2009 (9)
    • October 2009 (10)
    • September 2009 (14)
    • August 2009 (10)
    • July 2009 (1)
    • June 2009 (1)
    • May 2009 (1)
    • April 2009 (1)
    • March 2009 (1)
    • October 2008 (3)
    • October 2007 (3)
    • July 2007 (4)
    • June 2007 (1)
    • May 2007 (3)
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • Categories

    • News (16)
    • Ropardo Team (8)
    • Ropardo Products (6)
      • File Tracking Client (4)
      • iManagement (2)
    • Software Development (83)
      • Microsoft.NET (22)
      • Java (41)
      • Oracle (8)
      • Power Builder (3)
      • Liferay (5)
      • Lotus Notes (9)
      • xWiki (4)
    • System Adminstration (13)
      • Linux (10)
      • Windows (3)
    • Programming (1)
    • Uncategorized (3)
    • Databases (10)
      • MSSQL (5)
      • PostgreeSQL (3)
    • Microsoft.NET (1)
    • Web Development (28)
      • ASP/ASPX (3)
      • Content Management Systems (1)
      • HTML/CSS (5)
      • Javascrip/AJAX (8)
      • PHP (7)
    • Oracle E Business Suite (6)
  • Tags

    .NET ajax blog C# certification client CMS control css database Debugging django Domino Eclipse extension file tracking filter fun gentoo google Hibernate how to html image iManagement import Java javascript jQuery liferay Linux Lotus Notes lotus script Oracle Oracle BI Publisher 11g PHP portal PostgreSQL powerbuilder Python SQL Telerik velocity xml Xwiki

© 2012 ROPARDO s.r.l..

Powered by WordPress. Styled by Ropardo