I have tried a million different ways to install PyQt5, but I keep getting the same error message. I attempted to install it in a Python virtual environment, but still no success. I tried downloading Qt to see if there were any dependencies that were missing, but it did not resolve the issue. I have tried updating pip, using Homebrew, downloading the source code, and many other methods, but I have still been unable to install it. I'm working on MacOS.
This is an example of what I have tried:
(env) firstLast@name-MacBook-Pro project % pip install pyqt5
Collecting pyqt5
Using cached PyQt5-5.15.9.tar.gz (3.2 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
Querying qmake about your Qt installation...
Traceback (most recent call last):
File "/Users/name/Documents/final_project/tfod/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/Users/name/Documents/final_project/tfod/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/name/Documents/final_project/tfod/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/ky/630000/T/pip-build-env-129w2sdq/overlay/lib/python3.11/site-packages/sipbuild/api.py", line 46, in build_wheel
project = AbstractProject.bootstrap('wheel',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/ky/630000/T/pip-build-env-129w2sdq/overlay/lib/python3.11/site-packages/sipbuild/abstract_project.py", line 87, in bootstrap
project.setup(pyproject, tool, tool_description)
File "/private/var/folders/ky/630000/T/pip-build-env-129w2sdq/overlay/lib/python3.11/site-packages/sipbuild/project.py", line 602, in setup
self.update(tool)
File "/private/var/folders/ky/630000/T/pip-install-blf1r8si/pyqt5_7df68330104f4a9dbfac80220bfcd894/project.py", line 165, in update
raise UserException(
sipbuild.exceptions.UserException
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
On macOS, there is a known issue when trying to install PyQt5 that requires having Qt5 installed on the system and its qmake tool added to the system's PATH, as indicated in the installation section of its PyPI page.
To install Qt5, you can run the following command in terminal:
brew install qt5
After installation, you'll need to locate the qmake tool path, which is usually found here: /usr/local/opt/qt/bin/qmake. To add this path to the system's PATH, you'll need to open the .bash_profile file in terminal by typing:
nano ~/.bash_profile
Then, add the following line to the end of the file:
export PATH="/usr/local/opt/qt/bin:$PATH"
This will add the directory where qmake is installed to the system's PATH. Save and close the file by pressing Ctrl + X, then Y, and then Enter. To apply the changes to the current session, run the following command:
source ~/.bash_profile
You can verify that qmake is now on the PATH by running the following command:
which qmake
This should resolve the issue and allow you to install PyQt5.
The M1 chip was introduced in November 2020 and is based on the ARMv8.5 architecture, which is different from the x86_64 architecture used in Intel-based Mac computers. As a result, applications such as PyQt had to be compiled to include ARM-compatible binaries to run on the M1 chip. To address this issue, the Qt team developed universal binaries that are compatible with both Intel and Apple Silicon hardware.
However, these universal binaries are only available from version 6.2 and onwards. This can be confirmed by running the commands below:
aviolaris@arch:~$ curl -s https://pypi.org/pypi/PyQt5/json | jq -r '.releases | to_entries[] | .value[] | select(.filename | contains("universal")) | .url | split("/") | .[-1]'
aviolaris@arch:~$ curl -s https://pypi.org/pypi/PyQt6/json | jq -r '.releases | to_entries[] | .value[] | select(.filename | contains("universal")) | .url | split("/") | .[-1]'
PyQt6-6.2.0-cp36-abi3-macosx_10_14_universal2.whl
PyQt6-6.2.1-cp36-abi3-macosx_10_14_universal2.whl
PyQt6-6.2.2-cp36-abi3-macosx_10_14_universal2.whl
PyQt6-6.2.3-cp36-abi3-macosx_10_14_universal2.whl
PyQt6-6.3.0-cp37-abi3-macosx_10_14_universal2.whl
PyQt6-6.3.1-cp37-abi3-macosx_10_14_universal2.whl
PyQt6-6.4.0-cp37-abi3-macosx_10_14_universal2.whl
PyQt6-6.4.1-cp37-abi3-macosx_10_14_universal2.whl
PyQt6-6.4.2-cp37-abi3-macosx_10_14_universal2.whl
PyQt6-6.5.0-1-cp37-abi3-macosx_10_14_universal2.whl
PyQt6-6.5.0-cp37-abi3-macosx_10_14_universal2.whl
With that being said, if you explicitly prefer not to use PyQt6, which is compatible with your system's architecture, out of the box, you can attempt to install PyQt5 by utilizing Rosetta, a built-in emulator that enables you to run x86_64 software on ARM-based Mac computers.
To use Rosetta:
arch to verify that it says "x86_64" now.After completing these steps, you will be able to install PyQt5 in the Terminal_x86_64 app by typing the relevant pip command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With