操作系统安装好后,系统安装了python2.79和python3.42及pip
1、尝试用自带python3安装pyqt5
pip3 install pyqt5
会报错:
Downloading/unpacking pyqt5
Downloading PyQt5-5.15.4.tar.gz (3.3MB): 3.3MB downloaded
Running setup.py (path:/tmp/pip_build_lh/pyqt5/setup.py) egg_info for package pyqt5
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/usr/lib64/python3.4/tokenize.py", line 437, in open
buffer = builtins.open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip_build_lh/pyqt5/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/usr/lib64/python3.4/tokenize.py", line 437, in open
buffer = builtins.open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip_build_lh/pyqt5/setup.py'
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_lh/pyqt5
Storing debug log for failure in /home/lh/.pip/pip.log
2、安装新版python3,现在是python3.9.5
安装python需要的依赖
sudo yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
下载解压编译
cd Python-3.9.5/
./configure --prefix=/usr/local/python39
sudo make
报错
UILD_CORE_MODULE
/home/lh/Python-3.9.5/Modules/_ctypes/_ctypes.c:107:17: 致命错误:ffi.h:没有那个文件或目录
#include <ffi.h>
^
编译中断。
升级软件环境
sudo yum update -y
再编译
sudo make clean
./configure --prefix=/usr/local/python39
sudo make
sudo make install
安装正确会提示已安装pip、pip3,在/usr/local/python39/bin下,可以添加到环境变量路径。
3、安装pyqt5
/usr/local/python39/bin/pip3 install pyqt5
/usr/local/python39/bin/pip3 install pyqt5-tools
4、测试
/usr/local/python39/bin/python3 test1.py
报错
relocationerror:/opt/Qt5.12.1/Tools/QtCreator/lib/Qt/lib/libQt5DBus.so.5:symbol dbus_message_set_allow_interactive_authorization,version LIBDBUS_1_3 not defined in file libdbus-1.so.3 with link time reference
下载https://dbus.freedesktop.org/releases/dbus/dbus-1.13.10.tar.xz解压
cd dbus-1.13.10
./configure --prefix=/home/lh/.local/lib/python3.9/site-packages/PyQt5/Qt5/lib
make
cd ./dbus/.libs
sudo cp libdbus-1.so /home/lh/.local/lib/python3.9/site-packages/PyQt5/Qt5/lib
sudo cp libdbus-1.so.3 /home/lh/.local/lib/python3.9/site-packages/PyQt5/Qt5/lib
sudo cp libdbus-1.so.3.26.0 /home/lh/.local/lib/python3.9/site-packages/PyQt5/Qt5/lib
再测试
/usr/local/python39/bin/python3 test1.py
报错
symbol lookup error: /opt/Qt5.12.1/Tools/QtCreator/lib/Qt/plugins/platforms/../../lib/libQt5XcbQpa.so.5: undefined symbol: FT_Get_Font_Format
下载https://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.gz解压
cd freetype-2.10.0
./configure --prefix=/home/lh/.local/lib/python3.9/site-packages/PyQt5/Qt5/lib
make
cd ./objs/.libs
sudo cp libfreetype.so /home/lh/.local/lib/python3.9/site-packages/PyQt5/Qt5/lib
sudo cp libfreetype.so.6 /home/lh/.local/lib/python3.9/site-packages/PyQt5/Qt5/lib
sudo cp libfreetype.so.6.17.0 /home/lh/.local/lib/python3.9/site-packages/PyQt5/Qt5/lib
再测试
/usr/local/python39/bin/python3 test1.py
成功。
参考:https://blog.csdn.net/codeaftercode/article/details/107584151 解决中标麒麟7安装Qt5.12.1后无法启动的问题[LIBDBUS_1_3 not defined][FT_Get_Font_Format]