Mac-安装pyqt

本文记录了在Mac上安装PyQt5的过程,作者建议使用Wheels方式安装,因为直接从源码安装会遇到问题,如不兼容Qt版本等。尽管尝试了多种配置方法,但最终还是选择了官方推荐的Wheels方式进行安装,并成功运行了小示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

为后来者踩雷,大多数安装方式都是第二种,既麻烦又费时,安装方式有两种:

  • Installing from Wheels
  • Building and Installing from Source

采用第二种安装方式:遇到最严重的问题是:

Error: Failed to determine the detail of your Qt installation. Try again using
the --verbose flag to see more detail about the problem.

#目前还没有查到有效的解决办法,可靠的一些说法来自PyQt for Mac安装:推荐 Qt5.5+PyQt5 或者 Qt4.8+PyQt4 否则就会出现 Error: Failed to determine the detail of your Qt installation.

并且按照:Python - Mac下PyQt5环境搭建,的安装配置,还是会出现:

Error: Failed to determine the detail of your Qt installation. Try again using
the --verbose flag to see more detail about the problem.

所以,倒腾了半天,还是选择用第一种方式安装 pyqt5,有爱倒腾的小伙伴们,如果解决了那个问题,一定要通知我

PyQt5官方安装教程

brew install python3
pip3 install pyqt5
#或者
sudo pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pyqt5
$ python
>>> import PyQt5

安装完成,跑个小demo

import sys
from PyQt5 import QtCore, QtGui, QtWidgets
if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    w = QtWidgets.QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('Hello PyQt')
    w.show()
    sys.exit(app.exec_())

这里写图片描述
明天开始写代码

参考博文:https://blog.youkuaiyun.com/tymatlab/article/details/78625089

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值