参考博客:
https://blog.csdn.net/weixin_43305589/article/details/122519934
https://blog.csdn.net/no996yes885/article/details/130264118

0.通过homebrew安装pyqt

brew install pyqt

对于Apple Silicon会默认安装PyQt6,原生支持ARM架构,无需转译。

1.配置qt安装路径到.zshrc(好像不重要没啥用?)

在终端执行:

echo 'export PATH="/opt/homebrew/opt/qt@6/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/pyqt@6/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

代码的意思为将pyqt的配置文件路径写入到~/.zshrc 中。

通过vim查看是否将代码写入到~/.zshrc中。

2.配置qt到python的安装目录中

通过conda创建一个环境py_GUI,需要将qt文件复制到py_GUI环境的site-packages中。

cp -r /opt/homebrew/Cellar/pyqt/6.2.0/lib/python3.9/site-packages /Users/你的用户名/miniforge3/envs/环境名/lib/python3.9/site-packages

上述代码与homebrew与python安装位置有关,需要自己修改!

安装成功后的测试过程:

~ conda info -e
# conda environments:
#
base * /Users/lybing/miniforge3
py_GUI /Users/lybing/miniforge3/envs/py_GUI

~ conda activate py_GUI
(py_GUI) → ~ python
Python 3.9.9 | packaged by conda-forge | (main, Dec 20 2021, 02:41:06)
[Clang 11.1.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt6
>>>

3.配置QtDesigner与UI文件编译工具到PyCharm中