博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MAC LINUX 安装PYQT(事例)
阅读量:6648 次
发布时间:2019-06-25

本文共 4059 字,大约阅读时间需要 13 分钟。

MAC安装

1、安装命令:brew install pyqt

Warning: Your Xcode (4.6.3) is outdatedPlease install Xcode 5.0.Warning: It appears you have MacPorts or Fink installed.Software installed with other package managers causes known problems forHomebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.==> Installing dependencies for pyqt: qt, sip==> Installing pyqt dependency: qt==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/qt-4.8.5.mountain_lion.bottle.2.tar.gz######################################################################## 100.0%==> Pouring qt-4.8.5.mountain_lion.bottle.2.tar.gz==> CaveatsWe agreed to the Qt opensource license for you.If this is unacceptable you should uninstall.==> Summary?  /usr/local/Cellar/qt/4.8.5: 2777 files, 119M==> Installing pyqt dependency: sip==> Downloading http://download.sf.net/project/pyqt/sip/sip-4.15.2/sip-4.15.2.tar.gz######################################################################## 100.0%==> /usr/bin/python configure.py --destdir=/usr/local/Cellar/sip/4.15.2/lib/python2.7/site-packages --bindir=/usr/local/Cellar/sip/4.15.2/bin --incdir=/usr/local/Cellar/sip/4.15.2/i==> make==> make install==> make clean==> CaveatsFor non-homebrew python (2.x), you need to amend your PYTHONPATH like so:  export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATHThe sip-dir for Python 2.x is /usr/local/share/sip.The sip-dir for Python 3.x is /usr/local/share/sip3.==> Summary?  /usr/local/Cellar/sip/4.15.2: 9 files, 632K, built in 11 seconds==> Installing pyqt==> Downloading http://downloads.sf.net/project/pyqt/PyQt4/PyQt-4.10.3/PyQt-mac-gpl-4.10.3.tar.gz######################################################################## 100.0%==> /usr/bin/python configure.py --confirm-license --bindir=/usr/local/Cellar/pyqt/4.10.3/bin --destdir=/usr/local/Cellar/pyqt/4.10.3/lib/python2.7/site-packages --sipdir=/usr/local==> /usr/bin/python ./configure-ng.py --confirm-license --bindir=/usr/local/Cellar/pyqt/4.10.3/bin --destdir=/usr/local/Cellar/pyqt/4.10.3/lib/python2.7/site-packages --sipdir=/usr/==> make==> make install==> make clean==> CaveatsFor non-homebrew python (2.x), you need to amend your PYTHONPATH like so:  export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH==> Summary?  /usr/local/Cellar/pyqt/4.10.3: 560 files, 18M, built in 8.5 minutes

 2、添加路径到

  • 在~/.bash_profile 添加如下一行
    export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
  • 然后 source ~/.bash_profile

3、添加测试程序 w1.py

import sysimport timefrom PyQt4 import QtGui, QtCore, QtWebKitclass Sp():    def save(self):        print "call"        data = self.webView.page().currentFrame().documentElement().toInnerXml()        open("htm.txt","w").write(data)        print 'finished'        time.sleep(5)        print 'finisheed......2'         #sys.exit()            def txtfile(self):        print "starting..."        def main(self):        self.webView = QtWebKit.QWebView()              self.webView.load(QtCore.QUrl("http://www.taobao.com"))        self.webView.show()        QtCore.QObject.connect(self.webView,QtCore.SIGNAL("loadFinished(bool)"),self.save)app = QtGui.QApplication(sys.argv)s = Sp()#s.txtfile()s.main()sys.exit(app.exec_())#sys.exit()

4、执行程序

  • python w1.py
@~/Downloads $ python w1.py callfinishedfinisheed......2callfinishedfinisheed......2callfinishedfinisheed......2Traceback (most recent call last):  File "w1.py", line 6, in save    def save(self):KeyboardInterrupt

linux

我使用的是刚刚安装的UBUNTU

1 安装杂七杂八的软件

1.1 sudo apt-get install build-essential

1.2 我的的Python是2.6.5,所以我安装的命令是:sudo apt-get install python2.6-dev

1.3 sudo apt-get install flex

2 安装sip

  • 下载:http://www.riverbankcomputing.co.uk/software/sip/download/
  • 解压:tar -zxvf sip-4.15.4-snapshot-7a74623b6967.tar.gz
  • 安装:python configure.py
  • make
  • sudo make install

3 安装QT相关 sudo apt-get install libxext6 libxext-dev libqt4-dev libqt4-gui libqt4-sql qt4-dev-tools qt4-doc qt4-designer qt4-qtconfig

4 安装PYQT

  • 下载:http://www.riverbankcomputing.co.uk/software/pyqt/download
  • 解压:tar 省略
  • 编译:make (差不多半个小时)
  • sudo make install

成功啦! 

转载地址:http://ocuto.baihongyu.com/

你可能感兴趣的文章
PHP支付宝手机网站支付功能
查看>>
Lambda 表达式
查看>>
[杂谈]记第一次出差有感
查看>>
block的作用
查看>>
poj1163 数字三角形 (动态规划)
查看>>
层序中序生成树
查看>>
idea编辑器激活码
查看>>
CSS中的浮动和定位
查看>>
AutoCompleteTextView的简单使用
查看>>
HDOJ_ACM_下沙的沙子有几粒?
查看>>
WP7 XAML介绍
查看>>
Node.js能让Javascript写后端,为啥不让Python写前端?
查看>>
陶哲轩实分析 习题 12.5.8 :度量空间中有界闭集不一定是紧集
查看>>
使用VS2012遇到的问题
查看>>
20.元素分类--内联块状元素
查看>>
出错。instantiating servlet class(无法实例化servlet)
查看>>
应该做什么样的研究:以Google为例
查看>>
Windows Phone 8.1 页面导航
查看>>
web前端工程师全套教程免费分享
查看>>
非对称加密相关基础
查看>>