Issue with Matplotlib on Win32 and "ImportError: DLL load failed"

Dear all,

We are using Python 2.5, matplotlib and NumPy on Windows to assist
with the teaching for an undergraduate paper. On a small number of
installations, an error attempting to load some required DLL's is
being reported (on approx 3 machines out of approximately 60). There
doesn't appear to be any pattern with this - we can seen it on one
install of Windows Server 2008 and also on various versions of Windows
XP (Professional and Home).

Symptoms are, after a "from pylab import *", the following traceback:

Traceback (most recent call last):
  File "C:\Documents and
Settings\Jo\workspace\test\src\root\nested\__init__.py", line 2, in
<module>
    from pylab import *
  File "C:\Python25\Lib\site-packages\pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "C:\Python25\Lib\site-packages\matplotlib\pylab.py", line 206,
in <module>
    from matplotlib import mpl # pulls in most modules
  File "C:\Python25\Lib\site-packages\matplotlib\mpl.py", line 1, in <module>
    from matplotlib import artist
  File "C:\Python25\Lib\site-packages\matplotlib\artist.py", line 4, in <module>
    from transforms import Bbox, IdentityTransform, TransformedBbox,
TransformedPath
  File "C:\Python25\Lib\site-packages\matplotlib\transforms.py", line
34, in <module>
    from matplotlib._path import affine_transform
ImportError: DLL load failed: The specified module could not be found.

The following versions of software are being used on all installs:

jre-6u14-windows-i586.exe, matplotlib-0.98.3.win32-py2.5.exe,
numpy-1.3.0-win32-superpack-python2.5.exe and python-2.5.4.msi

Some assistance attempting to debug this issue would be appreciated (I
have an install where this fault has been observed along with another
that works fine). (Note: The issue persists when the interactive user
has admin rights.)

Regards,

Patrick

···

--
Dr Patrick Rynhart
Linux Systems Administrator / Team Leader
IT Support Group
School of Engineering and Advanced Technology
AgHort A Room 3.61
Turitea Campus
Massey University
NEW ZEALAND
Phone +64 6 350 9099 extn 2444

We have seen this problem several times before, and have labored hard
to banish it, but it always has a way of coming back to haunt us. I
am aware of a bug in python2.6 which causes mingw to build broken
win32 binaries, but am not aware of such a problem w/ python2.5,
which you appear to be using. We often use a program called
dependency walker to track these problems down:

  http://www.dependencywalker.com/

Open the problematic file (it should be
C:\Python25\Lib\site-packages\matplotlib\_path.pyd) and report any
errors you find here; it should tell you which DLLs are missing.
Search the good and the bad boxes for these DLL filenames and see if
it is a difference in the boxes, eg do the good boxes have the DLL and
the bad boxes not, and if so maybe you can figure out why (different
version in the OS patch level?). I am really interested to know the
difference in the boxes because it may give us the critical clue as to
why some users report this problem and others do not see it.

Also, on one of the bad boxes, could you try the new 0.99 release and
let me know if you have the same issue?

I build the python2.5 installers with mingw; Christoph builds the
python2.6 installers with Visual Studio precisely because mingw is
broken on python2.6. If we can't banish this bug on 2.5 w/ mingw, I
may have to lean on his generosity and ask him to make a python2.5
installer with Visual Studio as well.

JDH

PS: rereading your email, I see you are using 0.98.3. The first time
I read it, when I wrote the response above, I thought you were using
0.98.5.3 -- the .3 at the end tricked me. The latter is fairly
recent, and came out 10 months after 0.98.3, and we did several things
to fix exactly this dll problem in interim. At a minimum, you need to
be testing and installing 0.98.5.3. This is a very stable, bug fix
release, suitable for use in the classroom. I can't guarantee you
won't hit the same problem, but at least you will be using a version
that *shouldn't* have it, though I am still interested in the results
of the dependency walker tests above, because I have wasted so much
time trying to fix these win32 installers.

···

On Thu, Aug 6, 2009 at 8:48 PM, Patrick Rynhart<prynhart@...287...> wrote:

Dear all,

We are using Python 2.5, matplotlib and NumPy on Windows to assist
with the teaching for an undergraduate paper. On a small number of
installations, an error attempting to load some required DLL's is
being reported (on approx 3 machines out of approximately 60). There
doesn't appear to be any pattern with this - we can seen it on one
install of Windows Server 2008 and also on various versions of Windows
XP (Professional and Home).

Symptoms are, after a "from pylab import *", the following traceback:

Traceback (most recent call last):
File "C:\Documents and
Settings\Jo\workspace\test\src\root\nested\__init__.py", line 2, in
<module>
from pylab import *
File "C:\Python25\Lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Python25\Lib\site-packages\matplotlib\pylab.py", line 206,
in <module>
from matplotlib import mpl # pulls in most modules
File "C:\Python25\Lib\site-packages\matplotlib\mpl.py", line 1, in <module>
from matplotlib import artist
File "C:\Python25\Lib\site-packages\matplotlib\artist.py", line 4, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox,
TransformedPath
File "C:\Python25\Lib\site-packages\matplotlib\transforms.py", line
34, in <module>
from matplotlib._path import affine_transform
ImportError: DLL load failed: The specified module could not be found.

Hi,

here is a VS2003 build of matplotlib-0.99.0 for Python 2.5 for comparison:

<http://www.lfd.uci.edu/~gohlke/download/matplotlib-0.99.0.win32-py2.5.exe&gt;

Christoph

···

On 08/07/2009 00:27, John Hunter wrote:

On Thu, Aug 6, 2009 at 8:48 PM, Patrick Rynhart<prynhart@...287...> wrote:

Dear all,

We are using Python 2.5, matplotlib and NumPy on Windows to assist
with the teaching for an undergraduate paper. On a small number of
installations, an error attempting to load some required DLL's is
being reported (on approx 3 machines out of approximately 60). There
doesn't appear to be any pattern with this - we can seen it on one
install of Windows Server 2008 and also on various versions of Windows
XP (Professional and Home).

Symptoms are, after a "from pylab import *", the following traceback:

Traceback (most recent call last):
  File "C:\Documents and
Settings\Jo\workspace\test\src\root\nested\__init__.py", line 2, in
<module>
    from pylab import *
  File "C:\Python25\Lib\site-packages\pylab.py", line 1, in<module>
    from matplotlib.pylab import *
  File "C:\Python25\Lib\site-packages\matplotlib\pylab.py", line 206,
in<module>
    from matplotlib import mpl # pulls in most modules
  File "C:\Python25\Lib\site-packages\matplotlib\mpl.py", line 1, in<module>
    from matplotlib import artist
  File "C:\Python25\Lib\site-packages\matplotlib\artist.py", line 4, in<module>
    from transforms import Bbox, IdentityTransform, TransformedBbox,
TransformedPath
  File "C:\Python25\Lib\site-packages\matplotlib\transforms.py", line
34, in<module>
    from matplotlib._path import affine_transform
ImportError: DLL load failed: The specified module could not be found.

We have seen this problem several times before, and have labored hard
to banish it, but it always has a way of coming back to haunt us. I
am aware of a bug in python2.6 which causes mingw to build broken
win32 binaries, but am not aware of such a problem w/ python2.5,
which you appear to be using. We often use a program called
dependency walker to track these problems down:

   http://www.dependencywalker.com/

Open the problematic file (it should be
C:\Python25\Lib\site-packages\matplotlib\_path.pyd) and report any
errors you find here; it should tell you which DLLs are missing.
Search the good and the bad boxes for these DLL filenames and see if
it is a difference in the boxes, eg do the good boxes have the DLL and
the bad boxes not, and if so maybe you can figure out why (different
version in the OS patch level?). I am really interested to know the
difference in the boxes because it may give us the critical clue as to
why some users report this problem and others do not see it.

Also, on one of the bad boxes, could you try the new 0.99 release and
let me know if you have the same issue?

I build the python2.5 installers with mingw; Christoph builds the
python2.6 installers with Visual Studio precisely because mingw is
broken on python2.6. If we can't banish this bug on 2.5 w/ mingw, I
may have to lean on his generosity and ask him to make a python2.5
installer with Visual Studio as well.

JDH

PS: rereading your email, I see you are using 0.98.3. The first time
I read it, when I wrote the response above, I thought you were using
0.98.5.3 -- the .3 at the end tricked me. The latter is fairly
recent, and came out 10 months after 0.98.3, and we did several things
to fix exactly this dll problem in interim. At a minimum, you need to
be testing and installing 0.98.5.3. This is a very stable, bug fix
release, suitable for use in the classroom. I can't guarantee you
won't hit the same problem, but at least you will be using a version
that *shouldn't* have it, though I am still interested in the results
of the dependency walker tests above, because I have wasted so much
time trying to fix these win32 installers.

Dear John,

Many thanks for your detailed post with regard to how to troubleshoot
this issue. The use of dependency walker allowed me to determine that
affected systems were missing the Visual C/C++ shared runtime
libraries - in particular, MSVCP71.DLL (the version of the runtime
shipped with Microsoft Visual C++ .NET 2003) was missing on these
systems.

According to http://support.microsoft.com/default.aspx/kb/326922,
installing the .NET 1.1 framework should - as a side-effect - also
install this DLL. However, on Windows Server 2008 (the only box that
I have direct access to in a faulted state) this DLL didn't seem to
install when I installed the .NET 1.1 framework.

(Aside: This could be because Explorer in Vista/2K8 appears to hide
system files exceptionally well. Even after playing with the Windows
Desktop Search syntax I couldn't get a match. Dropping to a cmd
prompt and listing %systemroot%\system32 also didn't provide a match
for the DLL.)

On one of the student Windows XP machines, I copied the above DLL from
a working XP SP3 install to "C:\Python25\Lib\site-packages\matplotlib"
and confirmed that matplotlib then works correctly. Attempting the
same trick on Server 2K8 didn't work, but this is probably to be
expected (given that it's a major version change of Windows NT).
Also, I don't think that M$ permit redistribution of the runtime by
just copying a DLL across, so I have asked students to try installing
the .NET framework 1.1.

Thanks again for your help. Do you think that testing for the version
of the Visual C redistributable is required during an install of
matplotlib (and/or possibly at runtime).

Thanks again for your assistance - this has been most appreciated.

Regards,

Patrick

···

On Fri, Aug 7, 2009 at 7:27 PM, John Hunter<jdh2358@...287...> wrote:

On Thu, Aug 6, 2009 at 8:48 PM, Patrick Rynhart<prynhart@...287...> wrote:

Dear all,

We are using Python 2.5, matplotlib and NumPy on Windows to assist
with the teaching for an undergraduate paper. On a small number of
installations, an error attempting to load some required DLL's is
being reported (on approx 3 machines out of approximately 60). There
doesn't appear to be any pattern with this - we can seen it on one
install of Windows Server 2008 and also on various versions of Windows
XP (Professional and Home).

Symptoms are, after a "from pylab import *", the following traceback:

Traceback (most recent call last):
File "C:\Documents and
Settings\Jo\workspace\test\src\root\nested\__init__.py", line 2, in
<module>
   from pylab import *
File "C:\Python25\Lib\site-packages\pylab.py", line 1, in <module>
   from matplotlib.pylab import *
File "C:\Python25\Lib\site-packages\matplotlib\pylab.py", line 206,
in <module>
   from matplotlib import mpl # pulls in most modules
File "C:\Python25\Lib\site-packages\matplotlib\mpl.py", line 1, in <module>
   from matplotlib import artist
File "C:\Python25\Lib\site-packages\matplotlib\artist.py", line 4, in <module>
   from transforms import Bbox, IdentityTransform, TransformedBbox,
TransformedPath
File "C:\Python25\Lib\site-packages\matplotlib\transforms.py", line
34, in <module>
   from matplotlib._path import affine_transform
ImportError: DLL load failed: The specified module could not be found.

We have seen this problem several times before, and have labored hard
to banish it, but it always has a way of coming back to haunt us. I
am aware of a bug in python2.6 which causes mingw to build broken
win32 binaries, but am not aware of such a problem w/ python2.5,
which you appear to be using. We often use a program called
dependency walker to track these problems down:

http://www.dependencywalker.com/

Open the problematic file (it should be
C:\Python25\Lib\site-packages\matplotlib\_path.pyd) and report any
errors you find here; it should tell you which DLLs are missing.
Search the good and the bad boxes for these DLL filenames and see if
it is a difference in the boxes, eg do the good boxes have the DLL and
the bad boxes not, and if so maybe you can figure out why (different
version in the OS patch level?). I am really interested to know the
difference in the boxes because it may give us the critical clue as to
why some users report this problem and others do not see it.

Also, on one of the bad boxes, could you try the new 0.99 release and
let me know if you have the same issue?

I build the python2.5 installers with mingw; Christoph builds the
python2.6 installers with Visual Studio precisely because mingw is
broken on python2.6. If we can't banish this bug on 2.5 w/ mingw, I
may have to lean on his generosity and ask him to make a python2.5
installer with Visual Studio as well.

JDH

PS: rereading your email, I see you are using 0.98.3. The first time
I read it, when I wrote the response above, I thought you were using
0.98.5.3 -- the .3 at the end tricked me. The latter is fairly
recent, and came out 10 months after 0.98.3, and we did several things
to fix exactly this dll problem in interim. At a minimum, you need to
be testing and installing 0.98.5.3. This is a very stable, bug fix
release, suitable for use in the classroom. I can't guarantee you
won't hit the same problem, but at least you will be using a version
that *shouldn't* have it, though I am still interested in the results
of the dependency walker tests above, because I have wasted so much
time trying to fix these win32 installers.

--
Dr Patrick Rynhart
Linux Systems Administrator / Team Leader
IT Support Group
School of Engineering and Advanced Technology
AgHort A Room 3.61
Massey University (Turitea Campus)
NEW ZEALAND
Phone +64 6 356 9099 extn 2444

Hi again,

Just to update you, copying across the Visual C/C++ runtime library
(MSVCP71.DLL) from a Windows XP SP3 install to
C:\Python25\Lib\site-packages\matplotlib on Windows Server 2008 does
in fact appear to work correctly with matplotlib after all.

Regards,

Patrick

···

--
Dr Patrick Rynhart
Linux Systems Administrator / Team Leader
IT Support Group
School of Engineering and Advanced Technology
AgHort A Room 3.61
Massey University (Turitea Campus)
NEW ZEALAND
Phone +64 6 356 9099 extn 2444

This shouldn't be an issue with recent binaries of mpl, eg 0.99 and
later, so hopefully we won't have to worry about this install check.
I think we've fixed the MSVCP71.DLL problem, but if you experience
otherwise let us know.

JDH

···

On Tue, Aug 25, 2009 at 4:59 PM, Patrick Rynhart<prynhart@...287...> wrote:

Thanks again for your help. Do you think that testing for the version
of the Visual C redistributable is required during an install of
matplotlib (and/or possibly at runtime).