Python--PyQt5

记录python3.6搞定PyQt5(离线编译)
系统环境:Centos7.6
所依赖的环境:PyQt5 qmake-qt5 sip
过程中遇到的具体问题如下:
无法使用pip3 直接安装,主要原因为源码包未进行编译,故需要我们手动编译源码;

[root@node01 ~]# pip3 install PyQt5-5.15.4.tar.gz
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Processing ./PyQt5-5.15.4.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib64/python3.6/tokenize.py", line 452, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-h51_xom7-build/setup.py'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-h51_xom7-build/

一、安装初始化环境

yum install python36 -y
yum install python36-devel -y

二、安装PyQt5 相关依赖库

yum install qt5-qtbase-devel -y

yum install gcc gcc-c++ python-devel -y 

yum install qt5-qtquickcontrols qt5-qtdeclarative-devel -y

三、下载源码包

请注意版本

wget https://www.riverbankcomputing.com/static/Downloads/sip/4.19.25/sip-4.19.25.tar.gz
或者 yum install sip
wget https://files.pythonhosted.org/packages/28/6c/640e3f5c734c296a7193079a86842a789edb7988dca39eab44579088a1d1/PyQt5-5.15.2.tar.gz

[root@node02 tmp]# tar -zxvf PyQt5-5.15.2.tar.gz
[root@node02 tmp]# tar -zxvf sip-4.19.25.tar.gz
[root@node02 tmp]# cd sip-4.19.25
[root@node02 sip-4.19.25]# python3 configure.py
[root@node02 sip-4.19.25]# make && make install
[root@node02 sip-4.19.25]# which sip
/usr/bin/sip

[root@node02 tmp]# cd PyQt5-5.15.6/
[root@node02 PyQt5-5.15.6]# python3 configure.py --qmake=/usr/bin/qmake-qt5 --sip=/usr/bin/sip
[root@node02 PyQt5-5.15.6]# make && make install

编译完成后可直接使用

[root@node02 tmp]# cp -a PyQt5-5.15.6  /usr/lib64/python3.6/site-packages/PyQt5
[root@node02 tmp]# python3.6
Python 3.6.8 (default, Nov 16 2020, 16:55:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5
>>>

说明:
1)编译过程中报错如下:

Checking to see if the dbus support module should be built...
DBus v1 does not seem to be installed.
Qt v4.7.0 free edition is being used.
SIP 4.13.2 is being used.
The Qt header files are in /usr/include/qt4.
The shared Qt libraries are in /usr/lib.
The Qt binaries are in /usr/bin.
The Qt mkspecs directory is in /usr/share/qt4.
These PyQt modules will be built: QtCore, QtGui, QtHelp, QtNetwork, QtDBus,
QtDeclarative, QtOpenGL, QtScript, QtScriptTools, QtSql, QtSvg, QtTest,
QtWebKit, QtXml, QtXmlPatterns, QtDesigner.
The PyQt Python package will be installed in /usr/lib/python3/dist-packages.
PyQt is being built with generated docstrings.
PyQt is being built with 'protected' redefined as 'public'.
The Designer plugin will be installed in /usr/lib/qt4/plugins/designer.
The PyQt .sip files will be installed in /usr/share/sip/PyQt4.
pyuic4, pyrcc4 and pylupdate4 will be installed in /usr/bin.
Generating the C++ source for the QtCore module...
sip: /home/akhil/Desktop/PyQt-x11-gpl-4.9.1/sip/QtCore/QtCoremod.sip:28: syntax error
Error: Unable to create the C++ code.

解决方案:
PyQt5与sip的版本不对,需要降低其中的版本做对应便能解决此问题。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值