Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to install PyQt5 with pip

Im running into a problem installing PyQt5 with pip:

pip install pyqt5

DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
    Collecting pyqt5
      Using cached PyQt5-5.15.6.tar.gz (3.2 MB)
      Installing build dependencies ... done
      Getting requirements to build wheel ... done
      Preparing metadata (pyproject.toml) ... error
      ERROR: Command errored out with exit status 1:
       command: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /var/folders/rv/nylh_sjx44b1bq2pmbn1lwkr0000gn/T/tmpi8zk3o59
           cwd: /private/var/folders/rv/nylh_sjx44b1bq2pmbn1lwkr0000gn/T/pip-install-9w2kcz7l/pyqt5_a170d636f15d43c8bb4ae5d9a73574fc
      Complete output (24 lines):
      Querying qmake about your Qt installation...
      /opt/homebrew/bin/qmake -query
      Traceback (most recent call last):
        File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 156, in prepare_metadata_for_build_wheel
          hook = backend.prepare_metadata_for_build_wheel
      AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
    
      During handling of the above exception, another exception occurred:
    
      Traceback (most recent call last):
        File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 160, in prepare_metadata_for_build_wheel
          whl_basename = backend.build_wheel(metadata_directory, config_settings)
        File "/private/var/folders/rv/nylh_sjx44b1bq2pmbn1lwkr0000gn/T/pip-build-env-fyh98wta/overlay/lib/python3.9/site-packages/sipbuild/api.py", line 51, in build_wheel
          project = AbstractProject.bootstrap('pep517')
        File "/private/var/folders/rv/nylh_sjx44b1bq2pmbn1lwkr0000gn/T/pip-build-env-fyh98wta/overlay/lib/python3.9/site-packages/sipbuild/abstract_project.py", line 83, in bootstrap
          project.setup(pyproject, tool, tool_description)
        File "/private/var/folders/rv/nylh_sjx44b1bq2pmbn1lwkr0000gn/T/pip-build-env-fyh98wta/overlay/lib/python3.9/site-packages/sipbuild/project.py", line 603, in setup
          self.update(tool)
        File "project.py", line 160, in update
      sipbuild.exceptions.UserException
      ----------------------------------------

Im using macOS Monterey 12.0.1, with the Apple M1 chip.

What I've tried so far:

  • Installed PyQt5 using homebrew. Result: PyQt5 got installed via brew but without the necessary package PyQtWebengine. Means when I try to run my application, I receive the error message, that PyQtWebengine package/module is not installed which Im not able to install with pip. So I uninstalled it.
  • Installed sip and uninstalled
  • qt (6.2.2) and qt@5 (5.15.2) are installed with brew
  • Run cmd: python3 -m pip install PyQt5
  • Pip is up to date (21.3.1)
  • pip install with a specific PyQt5 Version

Any ideas to solve this problem? Thanks in advance for any ideas/solutions!

like image 458
Kojuru Avatar asked Aug 30 '25 16:08

Kojuru


1 Answers

The way I solved the same problem in my M1s was installing the library via terminal launched in Rosetta mode (left click on the Terminal icon -> Get Info -> Open in Rosetta).

So, detailed steps are:

  1. Open a Terminal with Rosetta 2 via left click on the Terminal icon -> Get Info -> Open in Rosetta (https://dev.to/courier/tips-and-tricks-to-setup-your-apple-m1-for-development-547g)

  2. Use non-homebrew python (mine was in /usr/bin/python3) to create virtual environment

$ /usr/bin/python3 -m venv venv
$ source venv/bin/activate
  1. Upgrade pip
(venv)$ pip install --upgrade pip
  1. Install PyQt5
(venv) $pip install PyQt5

Alternatively, you can do a one-off installation via this command:

$ arch -x86_64 python -m pip install PyQt5
like image 118
Luis U. Avatar answered Sep 02 '25 13:09

Luis U.