本文介绍了matplotlib 1.3.0 导入错误:DLL 加载失败:%1 不是有效的 Win32 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 2 台电脑(笔记本电脑和工作站),当我运行代码进行版本检查时,我在笔记本电脑上运行:

I have 2 pc (laptop and workstation), when I run code for version check I get on laptop:

computer
LAPTOP
OS props
Windows-7-6.1.7601-SP1
python props
('default', 'May 15 2013 22:44:16')
python version
2.7.5
OS bit and OS type
('64bit', 'WindowsPE')
check if system is 32bit or 64bit
('7fffffffffffffff', True)
numpy version
1.7.1
matplotlib version
1.3.0

在工作站上:

computer
WORKSTATION
OS props
Windows-7-6.1.7601-SP1
python props
('default', 'May 15 2013 22:44:16')
python version
2.7.5
OS bit and OS type
('64bit', 'WindowsPE')
check if system is 32bit or 64bit
('7fffffffffffffff', True)
numpy version
1.7.1
matplotlib version
1.3.0

除了一些额外的软件包外,软件基本相同.但是当我尝试在工作站计算机上运行以下代码时:

the software is mainly the same except some additional packages. But when I try to run the following code on the workstation computer:

import numpy as np
import matplotlib
# matplotlib.use('QTAgg')
from matplotlib import pyplot as plt

我收到以下错误:

Traceback (most recent call last):
  File "C:UsersWORKSTATIONpythonsrcgibljiv_kontakt_E11_vzmetpreview_and_sort_measurement_data.py", line 9, in <module>
    from matplotlib import pyplot as plt
  File "C:Python27libsite-packagesmatplotlibpyplot.py", line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "C:Python27libsite-packagesmatplotlibackends\__init__.py", line 28, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "C:Python27libsite-packagesmatplotlibackendsackend_tkagg.py", line 8, in <module>
    import Tkinter as Tk, FileDialog
  File "C:Python27liblib-tkTkinter.py", line 38, in <module>
    import FixTk
  File "C:Python27liblib-tkFixTk.py", line 65, in <module>
    import _tkinter
ImportError: DLL load failed: %1 is not a valid Win32 application

我想知道出了什么问题,如何修复?如果我取消注释该行,则代码有效(它不会返回任何错误):

I would like to know what is wrong and how can this be repaired? The code works (it does not return any error) if I uncomment the line:

matplotlib.use('QTAgg')

matplotlib.use('QTAgg')

但是当我用它来显示绘图时,没有显示绘图.任何建议有什么问题以及如何解决这个问题.我想补充一点,就像一个月前,在我更新工作站计算机上的 python 和 python 包之前,matplotlib 运行没有问题,但现在我收到了这个错误.

but as I use this for showing plots no plots are shown. Any suggestions what is wrong and how to fix this.I would like to add, that like a month ago before I updated python and python's packages on my workstation computer the matplotlib was working without problems, but now I get this error.

推荐答案

我已经解决了这个问题.解决方法如下:

I have solved the problem. Here is the solution procedure:

  1. 卸载 python 2.7.5(64 位)
  2. 重启电脑
  3. 安装 python 2.7.5(64 位)
  4. 重启电脑
  5. 它应该可以工作

如果我在卸载时选择修复选项,它并没有解决问题.感谢您的帮助@cgohlke.

If I choose the repair option when uninstalling, it didn't solve the problem. Thanks for your help @cgohlke.

这篇关于matplotlib 1.3.0 导入错误:DLL 加载失败:%1 不是有效的 Win32 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 16:00