本文介绍了为什么在Python3.4中PyQt5导入失败,并在Windows 7中出现“导入错误:DLL加载失败"的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Windows 7(64位操作系统)中安装了 32位 Python2.7,并且可以无任何错误地使用它.此外,我尝试在同一Windows 7中安装 64位 Python3.4和PyQt5.

I have 32-bit Python2.7 already installed in Windows 7 (64-bit Operating System) and I can use it without any errors. Besides, I attempted to install 64-bit Python3.4 and PyQt5 in the same Windows 7.

我遵循了此链接中给出的步骤:验证已安装的PyQt5软件包.我已经安装了 64位版本的Python3.4和PyQt5.如给定链接中所述,为了在输入时验证安装:from PyQt5 import QtCore, QtGui, QtWidgets我收到此错误:

I followed the steps given in this link: Verify PyQt5 Packages Installed. I have installed 64-bit versions of Python3.4 and PyQt5. As mentioned in the given link, in order to verify the installation when I typed: from PyQt5 import QtCore, QtGui, QtWidgets I got this error:

32位Python2.7是否可能导致此错误消息?

Is it possible that 32-bit Python2.7 causes this error message?

如何解决此问题?

提前谢谢!

推荐答案

情况太复杂.您有64位Windows,可以同时安装64位和32位软件.因此,您可以在两个版本中同时安装2.x和3.x.对于每种Python安装,可能有4种PyQt可用,即4& 5、32位和64位版本.因此,发生错误的可能性为2 * 4 * 4 * 2 = 64倍.开玩笑.

Too complex situation. You have 64-bit Windows, which can install both 64 and 32-bit software. So you can install both 2.x and 3.x in both variants. For each Python installation, there could be 4 type of PyQt available, 4 & 5, both in 32 and 64-bit version. So the possibility of error is 2 * 4 * 4 * 2 = 64 times complex. Jokes apart.

让我们看看错误:

ImportError: DLL load failed: %1 is not a valid Win32 application.

让我们分解一下:

  • ImportError:我们遇到的错误的性质与导入有关. Python无法加载指定的模块.让我们前进吧.
  • DLL load failed:此消息或多或少表示模块是.dll文件的形式.
  • %1 is not a valid Win32 application.此错误包含大多数信息. %1 ,它更像是表示PyQt5的参数,不是有效的Win32应用程序.
  • ImportError: Nature of error we are getting is Import related. Python is not able to load specified module(s). Let's move forward.
  • DLL load failed: This message more or less says that module was in form of .dll file.
  • %1 is not a valid Win32 application. This error has most of the info. %1, which is more like an argument representing PyQt5, is not a valid Win32 application.

通过查看错误,可以看出解释器正在寻找Win32应用程序,该应用程序仅表示32位应用程序.但是,为什么解释器需要一个32位模块?猜测?因为解释器本身是32位的!

By looking at the error, it can be seen that interpreter looking for a Win32 application, which simply means a 32-bit application. But why would interpreter want a 32-bit module? Guess? Because interpreter itself is 32-bit!

还不能说它是Python3或Python2解释器,因为错误仅指定32或64位信息.但是在您的情况下,它是您的Python 2解释器,因为它只是系统上的32位解释器.

It can't yet be said that it is Python3 or Python2 interpreter because error only specifies 32 or 64-bit information. But in your case it's your Python 2 interpreter because it's only the 32-bit interpreter on your system.

这篇关于为什么在Python3.4中PyQt5导入失败,并在Windows 7中出现“导入错误:DLL加载失败"的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 15:32