-
Notifications
You must be signed in to change notification settings - Fork 3.3k
64 bit pip installs 32 bit DLLs (PyQt5 and PySide2) #8649
Description
Environment
- pip version: 20.1.1
- Python version: 3.8
- OS: Windows 10
Installed Python for all users in custom location (%ProgramFiles%\Python38)
Description
Cannot run PyQt5 or PySide2 applications written in Python, either those I make myself or those also installed via pip.
Expected behavior
That 64 bit pip installs 64 bit DLLs so that Python scripts do not fail to load them. The code "from PyQt5.QtWidgets import QApplication" (or with PySide2 instead) should return without error.
How to Reproduce
Install packages PyQt5 and PySide2 with command "pip3 install pyqt5 pyside2" which I did from a console with admin privileges, though I don't think that matters.
Output
C:\Users\Jesse Maurais>python
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5.QtWidgets import QApplication
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing QtWidgets: %1 is not a valid Win32 application.
>>>
The "not a valid Win32 application" error is one I've seen before so I went to the site-packages folder and found the Qt DLLs that are installed with PyQt5 and PySide2. Running dumpbin on them to determine their architecture, found
C:\Program Files\Python38\Lib\site-packages\PyQt5\Qt\bin>dumpbin /headers Qt5Widgets.dll
Microsoft (R) COFF/PE Dumper Version 14.26.28806.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file Qt5Widgets.dll
PE signature found
File Type: DLL
FILE HEADER VALUES
14C machine (x86)
5 number of sections
5DB2AC3B time date stamp Fri Oct 25 02:03:07 2019
0 file pointer to symbol table
0 number of symbols
E0 size of optional header
2102 characteristics
Executable
32 bit word machine
DLL
Where the machine (x86) is the relevant information. Similarly for PySide2, found
C:\Program Files\Python38\Lib\site-packages\PySide2>dumpbin /headers Qt5Widgets.dll
Microsoft (R) COFF/PE Dumper Version 14.26.28806.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file Qt5Widgets.dll
PE signature found
File Type: DLL
FILE HEADER VALUES
14C machine (x86)
5 number of sections
5EB90FEE time date stamp Mon May 11 02:42:22 2020
0 file pointer to symbol table
0 number of symbols
E0 size of optional header
2102 characteristics
Executable
32 bit word machine
DLL
Then I double checked that the Python and pip executables were matching. They were not.
C:\Program Files\Python38>dumpbin /headers python.exe
Microsoft (R) COFF/PE Dumper Version 14.26.28806.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file python.exe
PE signature found
File Type: EXECUTABLE IMAGE
FILE HEADER VALUES
8664 machine (x64)
6 number of sections
5F15BF71 time date stamp Mon Jul 20 09:59:45 2020
0 file pointer to symbol table
0 number of symbols
F0 size of optional header
22 characteristics
Executable
Application can handle large (>2GB) addresses
Here we have machine (x64) and obviously a 64 bit program cannot load a 32 bit DLL (or vice versa). In fact no Qt app written in Python with these packages will even launch, exactly as I've observed. If pip cannot install 64 bit DLLs for Qt then it should not install these packages at all.