How to install PyQt5 on M1 arm64 architecture?
Asked Answered
F

3

4

I have an M1 mac, but I've noticed that whenever native python is running any automation script (like PyAutoGui) it progressively gets slower and slower, almost as if it's being throttled.

I created an environment with Miniforge3 that is able to utilise Apple's Silicon Chip, making the script run far quicker and more consistently as if it was running on an Intel mac, but I am struggling to install PyQt5 under the Miniforge3 environment, this seems to be an issue people are having, I suspect it's because the module hasn't been ported for arm64.

So I was wondering, is it possible for PyQt5 to run outside the environment, but the actual threads or functions of the application run inside the Miniforge3 environment that is running direction the M1 chip?

Or, is it possible to install PyQt5 on Miniforge3 running on Arm64 architecture?

I've exhausted all options for installing PyQt5.

Fandango answered 9/2, 2022 at 9:16 Comment(0)
M
4

This is a temporary solution as there does not seem to be any macos-arm64 build of PyQt5 available in the miniforge repositories just yet.

What I did is this:

arch -arm64 brew install pyqt@5
cd /Users/<myusername>/miniforge3/envs/<myenv>/lib/python3.9/site-packages
ln -s /opt/homebrew/Cellar/pyqt@5/5.15.6/lib/python3.9/site-packages/PyQt5 .

This is a very dirty workaround that installs PyQt5 built for the arm64 architecture system-wide and then symlinks it into the miniforge environment.

It will break as soon as the PyQt5 version will change due to upgrade.

I have nothing better than that for the moment, sadly...

Midstream answered 15/4, 2022 at 6:42 Comment(0)
M
3

Update: PyQt6 is available now and starting from version 6.2 it fully supports Apple silicon chips.

But ...

Following this answer, PyQt6 was not available for conda as of august 2021. After checking the available conda packages it sadly looks like that didn't change since then.

However, there are other ways to install PyQt.
To name one which worked for me instantly:

python3 -m pip install PyQt6
Mononucleosis answered 24/1, 2023 at 16:51 Comment(0)
R
0

It works if you install it with homebrew and specify the desired architecture.

arch -arm64 brew install pyqt@5

You can install homebrew here.

Don't forget to also specify the architecture when running a python script later on.

arch -arm64 python3 script.py

Furthermore, if you are using anaconda to create a virtual environment, you need to specify the architecture when creating the environment too.

CONDA_SUBDIR=osx-arm64 conda create --name myenv

I'm not sure if this is a solution to OP's question since I did not test it in an environment created with Miniforge3, but I can confirm that it works inside an anaconda environment on an M1 Mac.

Rattlebox answered 21/9, 2022 at 3:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.