Daniel Wang
Daniel Wang

Reputation: 113

matplotlib "DLL load failed" when import pylab

I'm new to matplotlib. My environment is WinXP, PythonWin 2.6.2, NumPy 1.3.0, matplotlib 0.98.5.3.

>>> import matplotlib.pylab as pylab
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "D:\Python26\lib\site-packages\matplotlib\pylab.py", line 253, in <module>
    from matplotlib.pyplot import *
  File "D:\Python26\lib\site-packages\matplotlib\pyplot.py", line 75, in <module>
    new_figure_manager, draw_if_interactive, show = pylab_setup()
  File "D:\Python26\lib\site-packages\matplotlib\backends\__init__.py", line 25, in pylab_setup
    globals(),locals(),[backend_name])
  File "D:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 8, in <module>
    import tkagg                 # Paint image to Tk photo blitter extension
  File "D:\Python26\lib\site-packages\matplotlib\backends\tkagg.py", line 1, in <module>
    import _tkagg
ImportError: DLL load failed: cannot find the module

I searched the web and it's said because lack of msvcp71.dll, but there is already one in my C:\windows\system32\

anyone can help? Thanks.

Upvotes: 1

Views: 7852

Answers (4)

Hogy86
Hogy86

Reputation: 1

I had this issue using iPython notebooks using Python 2.7. Apparently the latest Seaborn update does not play well with my local configuration settings, so I did "conda/pip install seaborn=0.5.1". It downgraded the necessary packages automatically, and my problem went away.

Upvotes: 0

DesaiM
DesaiM

Reputation: 1445

I actually found the answer and the graphs are running great on my computer. If you are getting a DLL error like this, try downloading msvcp71.dll and msvcr71.dll in your computer and then copy paste these two in your System32 folder:

C:\Windows\System32

and also copy-paste these two dll's in SysWOW64 folder if you are working on 64bit operating System

C:\Windows\SysWOW64

Now try running your code file in Python and it will load the graph in couple of seconds. Here is the link which says how to copy-paste dll's to both folder, this might help

http://www.youtube.com/watch?v=xmvRF7koJ5E

Cheers...

Upvotes: 0

peter
peter

Reputation:

I had the same problem installing activestat python 2.6 and pylab. After installing the sourceforge python 2.6.2 however it worked fine

Upvotes: 1

Anurag Uniyal
Anurag Uniyal

Reputation: 88737

try this, before using any other module

import matplotlib
matplotlib.use('Agg')

import matplotlib.pylab as pylab

see http://www.mail-archive.com/[email protected]/msg05372.html for more details and other ways

matplotlib can use different backends for rendering, agg is pure draw with no UI, so you can only save images e.g.

plt.savefig("plt.png")

read http://matplotlib.sourceforge.net/faq/installing_faq.html#what-is-a-backend for more details, e.g. you can output to ps, pdf, wxagg, tkagg etc, so if you have wxpython installed use this

matplotlib.use('wxagg')

also i think tkagg backend should have been work, as tkinter(http://wiki.python.org/moin/TkInter) is default gui with python, did you install python from python.org?

Upvotes: 8

Related Questions