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/python@3.9/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:
Any ideas to solve this problem? Thanks in advance for any ideas/solutions!
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:
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 )
Use non-homebrew python (mine was in /usr/bin/python3) to create virtual environment
$ /usr/bin/python3 -m venv venv
$ source venv/bin/activate
(venv)$ pip install --upgrade pip
(venv) $pip install PyQt5
Alternatively, you can do a one-off installation via this command:
$ arch -x86_64 python -m pip install PyQt5
I use macos 12.1 (m1), and I use mini-forge
with homebrew, I have installed pyqt5
with conda install pyqt
.
PS my python version is 3.9.
Opening Terminal using Rosetta as suggested by Luis U. also fixed my issue (MBP M1)
As I answered here , Rosetta is not required if you're willing to use Homebrew's pyqt@5. Homebrew includes an arm64-compiled pyqt5, and one can leverage its installation in a venv using the --system-site-packages
flag to venv
:
$ # Install pyqt5 via homebrew
$ brew install pyqt@5
$ # Note that it's installed in python3.9, not 3.10
$ brew cat pyqt@5 | grep 'depends_on.*python'
depends_on "python@3.9"
$ # Make a python3.9 virtualenv with access to the system's site-packages
$ /opt/homebrew/bin/python3.9 -m venv --system-site-packages .venv
$ source .venv/bin/activate
conda create -n py3.9.13 python=3.9.13
conda install pyqt
Worked for me. I'm using macOS Monterey 12.4, with the Apple M1 chip. Anaconda3
installed many dependences automatically while installing. After the above installation, my conda list
:
# Name Version
bzip2 1.0.8
ca-certificates 2022.6.15
gettext 0.19.8.1
glib 2.70.2
glib-tools 2.70.2
gst-plugins-base 1.20.3
gstreamer 1.20.3
icu 70.1
jpeg 9e
krb5 1.19.3
libclang 14.0.6
libclang13 14.0.6
libcxx 14.0.6
libedit 3.1.20191231
libffi 3.4.2
libglib 2.70.2
libiconv 1.16
libllvm14 14.0.6
libogg 1.3.4
libopus 1.3.1
libpng 1.6.37
libpq 14.4
libvorbis 1.3.7
libzlib 1.2.12
lz4-c 1.9.3
mysql-common 8.0.29
mysql-libs 8.0.29
ncurses 6.3
nspr 4.32
nss 3.78
openssl 1.1.1p
packaging 21.3
pcre 8.45
pip 22.1.2
ply 3.11
pyparsing 3.0.9
pyqt 5.15.4
pyqt5-sip 12.9.0
python 3.9.13
python_abi 3.9
qt-main 5.15.4
readline 8.1.2
setuptools 62.6.0
sip 6.6.2
sqlite 3.39.0
tk 8.6.12
toml 0.10.2
tzdata 2022a
wheel 0.37.1
xz 5.2.5
zlib 1.2.12
zstd 1.5.2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.