unable to import _graphviz

3,479 views
Skip to first unread message

myk_raniu

unread,
Nov 14, 2011, 9:28:39 AM11/14/11
to pygraphviz-discuss
Hi i have managed to install pygraphviz on windows 7 under python27.

Now i have a problem trying to import module pygraphviz in python

>>> import pygraphviz
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python26_32\lib\site-packages\pygraphviz\__init__.py", line
54, in <module>
from agraph import AGraph, Node, Edge, Attribute, ItemAttribute
File "C:\Python26_32\lib\site-packages\pygraphviz\agraph.py", line
19, in <module>
import graphviz as gv
File "C:\Python26_32\lib\site-packages\pygraphviz\graphviz.py", line
7, in <module>
import _graphviz
ImportError: DLL load failed: The specified procedure could not be
found.


So it looks like it is hitting an incompatiability problem when trying
to load from the DLL.

I am using the latest stable of graphviz (2.28) and of pygraphviz
(1.1)
Does anyone know how i can diagnose this on python?

I need to find out
- Which dll's python is trying to load
- What procedures it is trying to load from the DLL's

klo uo

unread,
Oct 4, 2012, 6:16:09 PM10/4/12
to pygraphvi...@googlegroups.com
This problem at my end, was caused because graphviz was not set in PATH env variable
It needed "cgraph.dll" library

Aquilai

unread,
Oct 27, 2012, 7:07:34 PM10/27/12
to pygraphvi...@googlegroups.com
I have the same problem. When I installed Graphviz 2.28 it already added the path C:\Program Files (x86)\Graphviz 2.28\bin to Win7's environment variables. The file cgraph.dll is inside C:\Program Files (x86)\Graphviz 2.28\bin but I still get the message:

import _graphviz
ImportError: DLL load failed: The specified module could not be found.

Any other ideas?

klo uo

unread,
Oct 27, 2012, 7:40:14 PM10/27/12
to pygraphvi...@googlegroups.com
I use XP and don't know if OS version has anything to do with the problem
I can suggest you load "_graphviz.pyd" and check for missing dependencies.
If you don't have anything better you can inspect with http://en.wikipedia.org/wiki/Dependency_Walker

Hope it helps

Cheers

klo uo

unread,
Oct 27, 2012, 7:42:36 PM10/27/12
to pygraphvi...@googlegroups.com
Forgot to mention that maybe it's better to install Graphviz in path without spaces
It's good practice no matter what installer defaults to

Aquilai

unread,
Oct 28, 2012, 10:56:41 AM10/28/12
to pygraphvi...@googlegroups.com
Thanks for pointing out Dependency Walker. I don't actually have a better program than "depends.exe" which seems to not be very helpful. It outputs this error:
Error: At least one required implicit or forwarded dependency was not found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
The modules it claims it can't find are:
msvcr90.dll  <- Can be found and added in the C:\Python27\Lib\site-packages\pygraphviz folder but error persists
gpsvc.dll  <- Unlikely to be needed since it relates to group policy and cannot be added since I use a 64bit system and there are no 32bit versions found
ieshims.dll  <- Same as msvcr90.dll but it will ask for more dlls

However, from using the dependency walker, I suspect now that there may be issues in compiling _graphicviz.pyd
Would it be convenient, legal or possible to upload your _graphicviz.pyd to download? I use Python 2.7 32bit.

Christoph Golfe, has uploaded windows binaries for many many python modules but unfortunately this isn't one of them. http://www.lfd.uci.edu/~gohlke/pythonlibs/

With regards to using non-space named directories, I don't think this is an issue. I can run binaries within "C:\Program Files (x86)\Graphviz 2.28\bin" perfectly fine (such as acyclic.exe) so the path environment variables should work even with spaces.

klo uo

unread,
Oct 28, 2012, 10:49:22 PM10/28/12
to pygraphvi...@googlegroups.com
On Sun, Oct 28, 2012 at 3:56 PM, Aquilai <yho...@gmail.com> wrote:
> Thanks for pointing out Dependency Walker. I don't actually have a better
> program than "depends.exe" which seems to not be very helpful. It outputs
> this error:
>>
>> Error: At least one required implicit or forwarded dependency was not
>> found.
>> Warning: At least one delay-load dependency module was not found.
>> Warning: At least one module has an unresolved import due to a missing
>> export function in a delay-load dependent module.
>
> The modules it claims it can't find are:
> msvcr90.dll <- Can be found and added in the
> C:\Python27\Lib\site-packages\pygraphviz folder but error persists
> gpsvc.dll <- Unlikely to be needed since it relates to group policy and
> cannot be added since I use a 64bit system and there are no 32bit versions
> found
> ieshims.dll <- Same as msvcr90.dll but it will ask for more dlls
>
> However, from using the dependency walker, I suspect now that there may be
> issues in compiling _graphicviz.pyd
> Would it be convenient, legal or possible to upload your _graphicviz.pyd to
> download? I use Python 2.7 32bit.

Well, I found my missing dependency with depend.exe.
Dependency scanner in PE Explorer (commercial) is easier to use, so
you can maybe try that

I attached my pygraphviz, which I use with Python 2.7 on XP 32bit


> Christoph Golfe, has uploaded windows binaries for many many python modules
> but unfortunately this isn't one of them.
> http://www.lfd.uci.edu/~gohlke/pythonlibs/

I also first look there ;)


> With regards to using non-space named directories, I don't think this is an
> issue. I can run binaries within "C:\Program Files (x86)\Graphviz 2.28\bin"
> perfectly fine (such as acyclic.exe) so the path environment variables
> should work even with spaces.

It's not about just running the executable, but graphviz has many
interfaces and spaces in path for some of those "interfaces", can
cause problems that needs further setting and digging in code that can
easily be avoided by having graphviz in clean path.
pygraphviz_python27.zip

Aquilai

unread,
Oct 29, 2012, 12:27:14 AM10/29/12
to pygraphvi...@googlegroups.com
The uploaded files worked great thanks a lot!

import pygraphviz

Now runs without any missing module errors ^^ I'll look into why compiling with mingw32 came up with a dodgy pyd when I have time.

胡傲果

unread,
Dec 20, 2012, 1:06:06 PM12/20/12
to pygraphvi...@googlegroups.com
Hi,have you found the reason?I meet the problem too,I use mingw,and when I replaced my _graphviz.pyd with the uploaded file it still does not work.

在 2012年10月29日星期一UTC+8下午12时27分14秒,Aquilai写道:
Reply all
Reply to author
Forward
0 new messages