linux 下开发桌面应用 PyQt
2014-05-22 16:22
627 查看
pyqt 这个包用 python 来做 QT 开发。下面详细介绍其步骤。
一、基础环境配置
二、在centos 下编译,安装QT-4.8.3
三、安装pyqt
四、测试
基本环境搭建
g++ 是必须安装的.
yum -y install gcc automake autoconf libtool make
yum install gcc-c++
在安装QT 之前,还有可能要执行如下的命令,安装需要的依赖包
yum install libX*
1. 安装python2.7
2. 更改python 软连接,因为centos 自带的python是 2.6.6
程序代码
cd /usr/bin
rm -rf python
ln -s /usr/local/bin/python2.7 python
这样做了之后,可能导致一个问题yum 命令不能用,这时需要修改yum
vi /usr/bin/yum
修改第一行的python路径 #!/usr/bin/python2.6 因为centos 是用的python2.6
安装PYQT SIP
下载 pyqt sip: http://nchc.dl.sourceforge.net/project/pyqt/sip/sip-4.14.1/sip-4.14.1.tar.gz
解压后 运行:
python configure.py
make
make install
安装PYQT
安装PYQT:http://nchc.dl.sourceforge.net/project/pyqt/PyQt4/PyQt-4.9.5/PyQt-x11-gpl-4.9.5.tar.gz
下载后解压.
程序代码
[root@localhost PyQt-x11-gpl-4.9.5]# python configure.py
[root@localhost PyQt-x11-gpl-4.9.5]# python configure.py
Error: Make sure you have a working Qt qmake on your PATH or use the -q
argument to explicitly specify a working Qt qmake.
报错提示没有 qmake,
因为没有安装QT,所以,还得安装QT,
下载地址: http://origin.releases.qt-project.org/qt4/source/qt-everywhere-opensource-src-4.8.3.tar.gz
解压之后:
程序代码
./configure (大约要10分钟)
结果如下:
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.3
make (要等很久)
make install (要等10分钟左右)
QT4.8.3 安装成功,你可以在安装目录/usr/local/Trolltech/Qt-4.8.3/bin/下 运行设计器 designer
然后再重新安装PYqT
程序代码
[root@localhost PyQt-x11-gpl-4.9.5]# python configure.py -q /usr/local/Trolltech/Qt-4.8.3/bin/qmake
Determining the layout of your Qt installation...
This is the GPL version of PyQt 4.9.5 (licensed under the GNU General Public
License) for Python 2.7.3 on linux2.
Type '2' to view the GPL v2 license.
Type '3' to view the GPL v3 license.
Type 'yes' to accept the terms of the license.
Type 'no' to decline the terms of the license.
Do you accept the terms of the license? yes
在configure 的时候,指定了qmake的路径.
成功之后,然后再
make (要等一段时间)
make install
成功运行命令后,PYQT 安装成功.你可以在python解析器下,运行import PyQt4 来检测是否安装成功.
测试脚本,并运行
程序代码
import sys
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
widget = QtGui.QWidget()
widget.resize(250, 150)
widget.setWindowTitle('yihaomen.com QT TEST')
widget.show()
sys.exit(app.exec_())
所以在centos 下安装qt,pyqt的关键就是,安装的顺序,另外 pyqt sip 也很重要,一定要在安装pyqt前安装,因为这个东西决定安装在那个python下面吧,如果有多个python在机器上。另外就是定qmake 的路径
一、基础环境配置
二、在centos 下编译,安装QT-4.8.3
三、安装pyqt
四、测试
基本环境搭建
g++ 是必须安装的.
yum -y install gcc automake autoconf libtool make
yum install gcc-c++
在安装QT 之前,还有可能要执行如下的命令,安装需要的依赖包
yum install libX*
1. 安装python2.7
2. 更改python 软连接,因为centos 自带的python是 2.6.6
程序代码
cd /usr/bin
rm -rf python
ln -s /usr/local/bin/python2.7 python
这样做了之后,可能导致一个问题yum 命令不能用,这时需要修改yum
vi /usr/bin/yum
修改第一行的python路径 #!/usr/bin/python2.6 因为centos 是用的python2.6
安装PYQT SIP
下载 pyqt sip: http://nchc.dl.sourceforge.net/project/pyqt/sip/sip-4.14.1/sip-4.14.1.tar.gz
解压后 运行:
python configure.py
make
make install
安装PYQT
安装PYQT:http://nchc.dl.sourceforge.net/project/pyqt/PyQt4/PyQt-4.9.5/PyQt-x11-gpl-4.9.5.tar.gz
下载后解压.
程序代码
[root@localhost PyQt-x11-gpl-4.9.5]# python configure.py
[root@localhost PyQt-x11-gpl-4.9.5]# python configure.py
Error: Make sure you have a working Qt qmake on your PATH or use the -q
argument to explicitly specify a working Qt qmake.
报错提示没有 qmake,
因为没有安装QT,所以,还得安装QT,
下载地址: http://origin.releases.qt-project.org/qt4/source/qt-everywhere-opensource-src-4.8.3.tar.gz
解压之后:
程序代码
./configure (大约要10分钟)
结果如下:
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.3
make (要等很久)
make install (要等10分钟左右)
QT4.8.3 安装成功,你可以在安装目录/usr/local/Trolltech/Qt-4.8.3/bin/下 运行设计器 designer
然后再重新安装PYqT
程序代码
[root@localhost PyQt-x11-gpl-4.9.5]# python configure.py -q /usr/local/Trolltech/Qt-4.8.3/bin/qmake
Determining the layout of your Qt installation...
This is the GPL version of PyQt 4.9.5 (licensed under the GNU General Public
License) for Python 2.7.3 on linux2.
Type '2' to view the GPL v2 license.
Type '3' to view the GPL v3 license.
Type 'yes' to accept the terms of the license.
Type 'no' to decline the terms of the license.
Do you accept the terms of the license? yes
在configure 的时候,指定了qmake的路径.
成功之后,然后再
make (要等一段时间)
make install
成功运行命令后,PYQT 安装成功.你可以在python解析器下,运行import PyQt4 来检测是否安装成功.
测试脚本,并运行
程序代码
import sys
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
widget = QtGui.QWidget()
widget.resize(250, 150)
widget.setWindowTitle('yihaomen.com QT TEST')
widget.show()
sys.exit(app.exec_())
所以在centos 下安装qt,pyqt的关键就是,安装的顺序,另外 pyqt sip 也很重要,一定要在安装pyqt前安装,因为这个东西决定安装在那个python下面吧,如果有多个python在机器上。另外就是定qmake 的路径
相关文章推荐
- 使用Pyqt在Linux下开发GUI桌面应用
- 使用Pyqt在Linux下开发GUI桌面应用
- 使用Pyqt在Linux下开发GUI桌面应用
- 使用Pyqt在Linux下开发GUI桌面应用
- Delphi 10.2可以开发Linux桌面应用了
- PHP开发Linux桌面应用和Android应用思路
- 轻松进入Linux的桌面应用开发.gambas初步认识.
- 开发嵌入式Linux Qtopia4.4.3桌面应用步骤(参考mini6410开发文档),针对于OK6410开发板
- Linux程序应用开发环境和工具经验谈
- linux的桌面应用~~感叹ing,超炫
- Linux程序应用开发环境和工具经验谈
- Linux程序应用开发环境和工具经验谈
- Maemo Linux手机平台系列分析:(15) Maemo应用开发
- 为您的 Linux 应用开发加油提速 2004: 安装 WebSphere Application Server Version 5.1
- Linux桌面应用问答(1)
- Linux程序应用开发环境和工具经验谈
- Linux程序应用开发环境和工具经验谈
- 志同道合 法中结成联盟开发Linux应用平台
- 嵌入式Linux开发工具选择和应用分析
- Linux下 桌面应用的几个小技巧