如何在 Python 3 (Ubuntu 14.04) 中安装 PyQt5
How to install PyQt5 in Python 3 (Ubuntu 14.04)
我需要将 Python2+PyQt4 的一些代码移植到 Python3+PyQt5。
我开始安装pip3
sudo apt-get install python3-pip
效果很好。尝试过
sudo pip3 install PyQt5
Downloading/unpacking PyQt5
Could not find any downloads that satisfy the requirement PyQt5
Cleaning up...
No distributions at all found for PyQt5
网上查到步骤如下:
http://pyqt.sourceforge.net/Docs/PyQt5/installation.html
但是他们太多了。在 Ubuntu 14.04 中安装 PyQt5 和 Python3 的最简单方法是什么?
为什么不直接通过 apt-get 安装它?
sudo apt-get install python3-pyqt5
否则您必须手动编译 PyQt(可能还有 Qt),这很麻烦。
好吧,我在这里记录了使用 qt 设计器和代码生成安装 pyqt5 的步骤:https://gist.github.com/ujjwal96/1dcd57542bdaf3c9d1b0dd526ccd44ff
安装
pip3 install --user pyqt5
sudo apt-get install python3-pyqt5
sudo apt-get install pyqt5-dev-tools
sudo apt-get install qttools5-dev-tools
正在从终端运行配置
$ qtchooser -run-tool=designer -qt=5
或
在/usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf
中写入以下内容
/usr/lib/x86_64-linux-gnu/qt5/bin
/usr/lib/x86_64-linux-gnu
代码生成
创建 uic.py 文件。
#!/usr/bin/python3
import subprocess
import sys
child = subprocess.Popen(['pyuic5' ,'-x',sys.argv[1]],stdout=subprocess.PIPE)
print(str(child.communicate()[0],encoding='utf-8'))
$ chmod +x uic.py
创建符号链接:
$ sudo ln uic.py "/usr/lib/x86_64-linux-gnu/qt5/bin/uic"
桌面条目
[Desktop Entry]
Name=Qt5 Designer
Icon=designer
Exec=/usr/lib/x86_64-linux-gnu/qt5/bin/designer
Type=Application
Categories=Application
Terminal=false
StartupNotify=true
Actions=NewWindow
Name[en_US]=Qt5 Designer
[Desktop Action NewWindow]
Name=Open a New Window
Exec=/usr/lib/x86_64-linux-gnu/qt5/bin/designer
保存在 ~/.local/share/application 中,扩展名为 .desktop
- sudo apt-get 安装 python3-pip
- sudo pip3 安装 PyQt5
我需要将 Python2+PyQt4 的一些代码移植到 Python3+PyQt5。
我开始安装pip3
sudo apt-get install python3-pip
效果很好。尝试过
sudo pip3 install PyQt5
Downloading/unpacking PyQt5
Could not find any downloads that satisfy the requirement PyQt5
Cleaning up...
No distributions at all found for PyQt5
网上查到步骤如下:
http://pyqt.sourceforge.net/Docs/PyQt5/installation.html
但是他们太多了。在 Ubuntu 14.04 中安装 PyQt5 和 Python3 的最简单方法是什么?
为什么不直接通过 apt-get 安装它?
sudo apt-get install python3-pyqt5
否则您必须手动编译 PyQt(可能还有 Qt),这很麻烦。
好吧,我在这里记录了使用 qt 设计器和代码生成安装 pyqt5 的步骤:https://gist.github.com/ujjwal96/1dcd57542bdaf3c9d1b0dd526ccd44ff
安装
pip3 install --user pyqt5
sudo apt-get install python3-pyqt5
sudo apt-get install pyqt5-dev-tools
sudo apt-get install qttools5-dev-tools
正在从终端运行配置
$ qtchooser -run-tool=designer -qt=5
或
在/usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf
/usr/lib/x86_64-linux-gnu/qt5/bin
/usr/lib/x86_64-linux-gnu
代码生成
创建 uic.py 文件。
#!/usr/bin/python3
import subprocess
import sys
child = subprocess.Popen(['pyuic5' ,'-x',sys.argv[1]],stdout=subprocess.PIPE)
print(str(child.communicate()[0],encoding='utf-8'))
$ chmod +x uic.py
创建符号链接:
$ sudo ln uic.py "/usr/lib/x86_64-linux-gnu/qt5/bin/uic"
桌面条目
[Desktop Entry]
Name=Qt5 Designer
Icon=designer
Exec=/usr/lib/x86_64-linux-gnu/qt5/bin/designer
Type=Application
Categories=Application
Terminal=false
StartupNotify=true
Actions=NewWindow
Name[en_US]=Qt5 Designer
[Desktop Action NewWindow]
Name=Open a New Window
Exec=/usr/lib/x86_64-linux-gnu/qt5/bin/designer
保存在 ~/.local/share/application 中,扩展名为 .desktop
- sudo apt-get 安装 python3-pip
- sudo pip3 安装 PyQt5