简体   繁体   English

如何在M1 arm64架构上安装PyQt5?

[英]How to install PyQt5 on M1 arm64 architecture?

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.我有一个 M1 mac,但我注意到每当本机 python 运行任何自动化脚本(如 PyAutoGui)时,它会逐渐变得越来越慢,几乎就像它被节流了一样。

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.我用 Miniforge3 创建了一个环境,它能够利用苹果的硅芯片,使脚本运行得更快、更一致,就像在 Intel mac 上运行一样,但我在 Miniforge3 环境下安装 PyQt5 很困难,这似乎是人们遇到的一个问题,我怀疑是因为该模块尚未移植到 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?所以我想知道,PyQt5 是否有可能在环境外运行,但应用程序的实际线程或功能在 M1 芯片运行方向的 Miniforge3 环境内运行?

Or, is it possible to install PyQt5 on Miniforge3 running on Arm64 architecture?或者,是否可以在 Arm64 架构上运行的 Miniforge3 上安装 PyQt5?

I've exhausted all options for installing PyQt5.我已经用尽了安装 PyQt5 的所有选项。

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.这是一个临时解决方案,因为 miniforge 存储库中似乎还没有 PyQt5 的任何 macos-arm64 版本。

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.这是一个非常肮脏的解决方法,它安装了为 arm64 体系结构系统范围构建的 PyQt5,然后将其符号链接到 miniforge 环境中。

It will break as soon as the PyQt5 version will change due to upgrade.一旦 PyQt5 版本因升级而发生变化,它将立即中断。

I have nothing better than that for the moment, sadly...我暂时没有比这更好的了,可悲的是......

It works if you install it with homebrew and specify the desired architecture.如果您使用homebrew安装它并指定所需的架构,它就可以工作。

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.稍后在运行 python 脚本时不要忘记指定架构。

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.此外,如果您使用 anaconda 创建虚拟环境,您还需要在创建环境时指定架构。

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.我不确定这是否是 OP 问题的解决方案,因为我没有在使用 Miniforge3 创建的环境中对其进行测试,但我可以确认它在 M1 Mac 上的 anaconda 环境中工作。

Update: PyQt6 is available now and starting from version 6.2 it fully supports Apple silicon chips.更新: PyQt6现已可用,从 6.2 版开始,它完全支持 Apple 硅芯片。

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.按照这个答案,截至 2021 年 8 月,PyQt6 不可用于 conda。在检查了可用的 conda 包之后,遗憾的是它看起来从那时起就没有改变。

However, there are other ways to install PyQt.但是,还有其他方法可以安装 PyQt。
To name one which worked for me instantly:举出一个立即对我有用的名字:

python3 -m pip install PyQt6

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在装有 M1 芯片(ppc64el 架构)的 Mac 上运行 pyqt5? - How can I run pyqt5 on my Mac with M1chip (ppc64el architecture)? 在 macOS - 12.0 M1 ( arm64 ) 中使用 pyenv 安装 python 3.5.10 时出现问题 - Issue in installing python 3.5.10 using pyenv in macOS - 12.0 M1 ( arm64 ) 如何在M1(Apple Silicon / Darwin-arm64)上安装和导入Scipy、Numpy、NumExpr等? - How to install and import Scipy, Numpy, NumExpr and others on M1 (Apple Silicon / Darwin-arm64)? 为 arm64 架构编译 python 模块 - Compile python modules for arm64 architecture 如何将我的环境架构从 x86-64 更改为 arm64? - How can I change my environment architecture to arm64 from x86-64? 如何创建可以在arm64和x86_64架构之间切换的conda环境? - How to create a conda environment that can switch between arm64 and x86_64 architecture? 如何在 Apple Silicon (ARM / M1) 上安装 SciPy - How to install SciPy on Apple Silicon (ARM / M1) 如何安装 PyQt5? - How to install the PyQt5? arch x86_64 和 arm64e 可用但 python3 在 Mac M1 上说不兼容的架构 - arch x86_64 and arm64e is available but python3 is saying incompatible architecture on Mac M1 mach-o 文件,但架构不兼容,有 'x86_64',需要 'arm64e' M1 MAC - mach-o file, but is an incompatible architecture have 'x86_64', need 'arm64e' M1 MAC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM