PyQt安装

这篇博客详细介绍了在Linux和Mac上安装PyQt的过程,包括下载Qt和PyQt安装包,解决在Linux环境下安装时遇到的问题,以及Mac上安装PyQt4和PyQt5的步骤和可能遇到的模块导入错误。

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

安装包下载

Linux安装PyQt4

主要参考文档 CentOS6.5安装PyQt4

成功安装的各个组件的版本号:
成功安装的各个组件的版本号

巨坑 安装sip-4.19,等安装PyQt4_gpl_x11-4.12.3的时候提示sip版本太低,所以使用PyQt-x11-gpl-4.11.4,但是在执行make的时候报错,最后是使用sip-4.19.12,以及PyQt4_gpl_x11-4.12.3,得以成功。

make时遇到如下问题,试着按照链接的文档解决,没有作用

make: *** No targets specified and no makefile found. Stop.

https://blog.youkuaiyun.com/l1028386804/article/details/48710993

安装Qt时执行./configure成功后打出的log最后应该长这样

Qt is now configured for building. Just run 'gmake'.
Once everything is built, you must run 'gmake install'.
Qt will be installed into /usr/local/Trolltech/Qt-4.8.7

To reconfigure, run 'gmake confclean' and 'configure'.

CentOS6.5默认Python2.6版本,安装包的路径在/usr/lib64/python2.6/site-packages


Mac安装PyQt4

主要参考文档 PyQt for Mac安装

操作时注意qmake路径

which qmake

python configure-ng.py -q /usr/bin/qmake -d /Library/Python/2.7/site-packages/ --sip /System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip

sip模块安装失败参考 Mac SIP系统完整性保护

其他搜到的文档
https://blog.youkuaiyun.com/watsy/article/details/8857252
https://blog.youkuaiyun.com/wdkirchhoff/article/details/22572599
https://blog.youkuaiyun.com/longchena/article/details/79204596


Mac安装PyQt5

➜ ~ brew install python3

Python has been installed as
/usr/local/bin/python3
If you need Homebrew’s Python 2.7 run
brew install python@2
Pip, setuptools, and wheel have been installed. To update them run
pip3 install --upgrade pip setuptools wheel
You can install Python packages with
pip3 install
They will install into the site-package directory
/usr/local/lib/python3.7/site-packages

➜ ~ which python

/usr/bin/python

➜ ~ which python3

/usr/local/bin/python3

➜ ~ sudo easy_install pip3

No local packages or download links found for pip3
error: Could not find suitable distribution for Requirement.parse(‘pip3’)

➜ ~ cd /usr/local/bin

➜ bin pip3.7 install sip

Successfully installed sip-4.19.8

➜ bin pip3.7 install sip

Requirement already satisfied: sip in /usr/local/lib/python3.7/site-packages (4.19.8)

➜ bin pip3.7 install PyQt5

Successfully installed PyQt5-5.11.2 PyQt5-sip-4.19.12


>>> from PyQt5.QtWebKit import *
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘PyQt5.QtWebKit’

>>> from PyQt5.QtWebKitWidgets import *
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘PyQt5.QtWebKitWidgets’

PyQt5跟PyQt4很多模块已经不一致

https://www.cnblogs.com/zxpo/p/7562968.html

from PyQt5.QtWebEngineWidgets import *

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值