matplotlib“DLL 加载失败” 当导入pylab时

发布于 2024-07-26 00:57:40 字数 1110 浏览 2 评论 0原文

我是 matplotlib 的新手。 我的环境是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

我在网上搜索了一下,据说是因为缺少msvcp71.dll,但我的C:\windows\system32\ 中已经有一个,

有人可以帮忙吗? 谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

魂牵梦绕锁你心扉 2024-08-02 00:57:40

尝试这个,在使用任何其他模块之前

import matplotlib
matplotlib.use('Agg')

import matplotlib.pylab as pylab

请参阅 http:// www.mail-archive.com/[电子邮件受保护]/msg05372.html了解更多详细信息和其他

matplotlib 可以使用不同的 方式用于渲染的后端, agg 是纯绘图,没有 UI,因此您只能保存图像,例如

plt.savefig("plt.png")

读取 http://matplotlib.sourceforge.net/faq/installing_faq.html#what-is-a-backend 了解更多详细信息,例如您可以输出到 ps、pdf、wxagg、tkagg 等,所以如果你安装了 wxpython,

matplotlib.use('wxagg')

我也认为 tkagg 后端应该可以工作,因为 tkinter(http:// wiki.python.org/moin/TkInter) 是带有 python 的默认 gui,你是从 python.org 安装 python 的吗?

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?

蓝色星空 2024-08-02 00:57:40

我在安装 activestat python 2.6 和 pylab 时遇到了同样的问题。 安装sourceforge python 2.6.2后,它工作正常

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

落在眉间の轻吻 2024-08-02 00:57:40

我实际上找到了答案,并且图表在我的计算机上运行得很好。 如果您遇到这样的 DLL 错误,请尝试在计算机中下载 msvcp71.dll 和 msvcr71.dll,然后将这两个文件复制粘贴到您的 System32 文件夹中:

C:\Windows\System32

,如果您使用的是 64 位操作系统,请将这两个 dll 复制粘贴到 SysWOW64 文件夹中

C:\Windows\SysWOW64

现在尝试在 Python 中运行代码文件,它将在几秒钟内加载图形。 这是说明如何将 dll 复制粘贴到这两个文件夹的链接,这可能会有所帮助

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

干杯...

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...

梦里南柯 2024-08-02 00:57:40

我在使用 Python 2.7 的 iPython 笔记本时遇到了这个问题。 显然最新的 Seaborn 更新与我的本地配置设置不能很好地配合,所以我做了“conda/pip install seaborn=0.5.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文