linux 安装pyqt5

linux 安装pyqt5,第1张

安装 sip

此时sip安装在python文件夹中,未进入系统路径,这时候在命令行中输入 :

sip -V #会提示找不到sip

本机中python 通过sys.path(),找到路径为:/usr/local/python3 ;sip在其bin 文件夹下面

请执行

进入PyQt文件夹

python configure.py

make

sudo make install

一、通过系统的软件包管理器安装ipython软件包。

1、ubuntu直接用以下命令:

#apt-get install ipython

//ubuntu将ipython的库文件安装到/usr/share/python-support/ipython目录下,包括一系列.pth文件和符号链接,而ipython的二进制文件则安装在/usr/bin/ipyton目录下。

2、redhat(centos)使用下面的命令:

#yum list | grep ipython

//查看所使用的yum源是否有ipython包,没有的话,就只能换源或者源码安装了。

#yum install ipython.noarch

//安装ipython

二、下载tar包安装方法:

1、 解压:

[root@CentOS_1 ~]# tar xf Python-2.7.8

2、进入解压后的文件夹Python-2.7.8,编译

[root@centos_1 Python-2.7.8]# ./configure --prefix=/usr/local/python2.7

3、make安装

[root@centos_1 Python-2.7.8]# make &&make

安装Ipython

1、下载Ipython

下载Ipython的源码包ipython-3.0.0.tar.gz。

2、解压安装包

[root@centos_1 tmp]# tar zxvf ipython-3.0.0

3、安装readline-devel包

在编译安装Ipython之前,确保已经安装了readline-devel包,否则安装完成后,IPython将无法正常输入

[root@centos_1 ~]# yum install readline-devel

3、使用Python2.7.8编译安装。

[root@centos_1 ipython-3.0.0]# /usr/local/python2.7/bin/python setup.py build

[root@centos_1 ipython-3.0.0]# /usr/local/python2.7/bin/python setup.py install

4、安装完成之后,会在Python2.7.8的bin目录下面生成一个IPython的可执行文件,为了方便使用,将IPython连接到/usr/bin目录下面。

[root@centos_1 bin]# ln -sf ipython /usr/bin/ipython

以Ubuntu 12.10下搭建PyQt环境为例!

make

安装Python(由于此版本默认有Python2.7和Python3.2故可省去)

第一步:下载Qt4源代码

第二步:下载SIP( SIP is a tool forautomatically generating Python bindings for C andC++ libraries)

第三步:下载PyQt

第四步:配置SIP:

解压sip-XXXXX.tar.gz压缩包,进入sip-XXXXX目录

运行

python configure.py

注意:If you have multiple versions of Python installed then make sure

you use theinterpreter for which you wish SIP to generate bindings for.

也就是说我采用Python3.x进行开发,那么使用的命令是:python3 configure.py

shell下的结果是:

lieo@ubuntu:~/download/sip-4.14.2$ python3 configure.py

This is SIP 4.14.2 for Python 3.2.3 on linux2.

The SIP code generator will be installed in /usr/bin.

The sip module will be installed in /usr/lib/python3/dist-packages.

The sip.h header file will be installed in /usr/include/python3.2mu.

The default directory to install .sip files in is /usr/share/sip.

make

注意: 这步可能会报找不到Python.h文件的错误(没报错跳到make install)

这是因为缺失头文件和静态库包,

假如使用python2.7运行

sudo apt-get install python-dev

假如使用python3运行

sudo apt-get install python3-dev

make install

第五步:编译安装Qt4

Ubuntu默认没有编译环境,运行以下命令安装编译环境

sudo apt-get install build-essential

#进入qt源码目录运行

./configure

结果:Qt will be installed into /usr/local/Trolltech/Qt-4.8.4

make

make install

1.如果在./configure阶段,出现了以下错误

Basic XLib functionality test failed!

You might need to modify the include and library search paths by editing

QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11

那是因为没装有libxtst-dev,使用命令apt-get install libxtst-dev安装

2.如果在make阶段,出现一下错误

/usr/bin/ld: cannot find -lXrender

make[1]: *** [../../../../lib/libQtWebKit.so.4.7.3] 错误 1

make: *** [sub-webkit-make_default-ordered] 错误 2

那是因为没有装libxrender-dev

3.在qt create中,尝试编译测试,如果找不到qmake,则在工具-选项-QT4中手动设置qmake的位置。qmake的位置默认在/usr/local/Trolltech/Qt-4.8.4/bin/qmake。

当这几个步骤全部完成后,把“PATH=/usr/local/Trolltech/Qt-4.8.4/bin:$PATH

export PATH”加到.profile中,Qt就安装成功了。

或者 在.bashrc文件(如果你的shell是bash、ksh、zsh或者sh)中,添加下面这些行:

QTDIR=/usr/local/Trolltech/Qt-4.8.4

PATH=$QTDIR/bin:$PATH

LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH

第六步:安装PyQt

#进入PyQt源码目录运行以下命令安装PyQt

#前提是Qt4和SIP以正确安装

python configure.py

make

make install

至此配置完成


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/7224394.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-03
下一篇2023-04-03

发表评论

登录后才能评论

评论列表(0条)

    保存