Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

python - Why PyQt5 import failed in Python3.4 with `ImportError: DLL load failed` in Windows 7?

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.

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:

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

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

How can I fix this problem?

Thanks in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

Let's look at the error:

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

Let's break it down:

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

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!

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...