NameError: global name 'libgv' is not defined
I was encountering another issue and have provided a solution below. Note this was from version 2.7 built on Scientific Linux without root, so I assumed I may have many path issues.
Traceback (most recent call last):
File "graphviz_example.py", line 46, in <module>
graphviz_draw(g, overlap = False)
File "/home/USER/.local/Python-2.7.11/lib/python2.7/site-packages/graph_tool/draw/graphviz_draw.py", line 587, in graphviz_draw
libgv.agclose(gvg)
NameError: global name 'libgv' is not defined
I am testing by using the example from here:
http://openstackwiki.org/wiki/Werkzeuge_-_NameError_Graph:_Namen_der_globalen_'_Libgv_'_ist_nicht_definiert
libname = ctypes.util.find_library("gvc")
returns None in file
/home/USER/.local/Python-2.7.11/lib/python2.7/site-packages/graph_tool/draw/graphviz_draw.py
.
I was able to correct the issue by pointing directly to libgv in the graphviz_draw.py
file and adding '/home/USER/.local/graphviz-2.38.0/lib' in $LD_LIBRARY_PATH, similar to the procedure described in this reference
http://www1.se.cuhk.edu.hk/~hmleung/wordpress/?p=1474
libname = ctypes.util.find_library("gvc")
#if libname is None:
# raise OSError('gvc does not exist.')``
#libgv = ctypes.CDLL(libname, ctypes.RTLD_GLOBAL)
libgv = ctypes.CDLL("libgvc.so", ctypes.RTLD_GLOBAL)