首页 > 代码库 > pyQt4 for mac OS 10.8
pyQt4 for mac OS 10.8
pyQt4 for mac OS 10.8
2013-04-27 06:59 5744人阅读 评论(0) 收藏 举报
分类:
版权声明:本文为博主原创文章,未经博主允许不得转载。
因为想跨平台,所以考虑Qt,又想结合脚本的便捷。考虑PyQt
网上搜索了一下,资料挺少的。有的还是以前的资料。
参考这里 http://www.noktec.be/Python/how-to-install-pyqt4-on-osx
1:下载安装Qt
http://qt-project.org/downloads
我下载的是Qt 5.0.2 for Mac (404 MB) (Info)
安装起来还挺方便的。不说了
2:下载SIP
http://www.riverbankcomputing.co.uk/software/sip/download
我下载的是 sip-4.14.7-snapshot-bd9eccac4407.tar.gz
下载以后解压
[plain] view plain copy
- cd sip-4.14.7-snapshot-bd9eccac4407
- python configure.py -d /Library/Python/2.7/site-packages --arch=i386
- make
- sudo make install
安装起来没问题。
3:下载PyQt4
http://www.riverbankcomputing.co.uk/software/pyqt/download
我下载的是 PyQt-mac-gpl-snapshot-4.10.2-ffcf323516fc.tar.gz
下载后解压安装配置这里要参考改版后的配置文档,新版本用的是configure-ng.py:
http://pyqt.sourceforge.net/Docs/PyQt4/installation.html#configuring-pyqt4
命令
[plain] view plain copy
- cd PyQt-mac-gpl-snapshot-4.10.2-ffcf323516fc
- python configure-ng.py -q /Users/watsy/Qt5.0.2/5.0.2/clang_64/bin/qmake -d /Library/Python/2.7/site-packages/ --sip /System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip
- make
- sudo make install
以上步骤完成以后,运行demo
[python] view plain copy
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- """
- ZetCode PyQt4 tutorial
- In this example, we create a simple
- window in PyQt4.
- author: Jan Bodnar
- website: zetcode.com
- last edited: October 2011
- """
- import sys
- from PyQt4 import QtGui
- def main():
- app = QtGui.QApplication(sys.argv)
- w = QtGui.QWidget()
- w.resize(250, 150)
- w.move(300, 300)
- w.setWindowTitle(‘Simple‘)
- w.show()
- sys.exit(app.exec_())
- if __name__ == ‘__main__‘:
- main()
执行得到如下错误
[python] view plain copy
- Traceback (most recent call last):
- File "pyqtDemo.py", line 16, in <module>
- from PyQt4 import QtGui
- ImportError: dlopen(/Library/Python/2.7/site-packages/sip.so, 2): no suitable image found. Did find:
- /Library/Python/2.7/site-packages/sip.so: mach-o, but wrong architecture
在考虑是什么问题
查看
[plain] view plain copy
- lipo -info /Library/Python/2.7/site-packages/sip.so
得到
[plain] view plain copy
- Non-fat file: /Library/Python/2.7/site-packages/sip.so is architecture: i386
想来现在机器用的是64位系统了。
修改 sip的配置从新编译
[python] view plain copy
- cd sip-4.14.7-snapshot-bd9eccac4407
- python configure.py -d /Library/Python/2.7/site-packages --arch=x86_64
- make
- sudo make install
安装碗以后运行demo
perfect~
pyQt4 for mac OS 10.8
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。