Reputation: 2450
I need to port some code that's Python2+PyQt4 to Python3+PyQt5.
I started installing pip3
sudo apt-get install python3-pip
Works great. Tried
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
Online I find the following steps:
http://pyqt.sourceforge.net/Docs/PyQt5/installation.html
But they are too many. What's the easiest way to Install PyQt5 along with Python3 in Ubuntu 14.04 ?
Upvotes: 31
Views: 115626
Reputation: 361
Well I documented the steps for Installing pyqt5 with qt designer and code generation here: https://gist.github.com/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
OR
Write the following in /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
Create uic.py file.
#!/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
Create a symlink:
$ 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
save in ~/.local/share/application with .desktop extension
Upvotes: 26
Reputation: 53215
Tested on Ubuntu 18.04.
Just installing it did not work for me. I had to uninstall it first, then reinstall it:
# upgrade pip
python3 -m pip install --upgrade pip
# uninstall
python3 -m pip uninstall PyQt5
python3 -m pip uninstall PyQt5-sip
python3 -m pip uninstall PyQtWebEngine
# reinstall
python3 -m pip install PyQt5
python3 -m pip install PyQt5-sip
python3 -m pip install PyQtWebEngine
See here for my full answer, including how to install it for a specific version of Python3, such as Python3.8: How to install PyQt5 in Python3
Upvotes: 0
Reputation: 11989
Why not simply install it via apt-get?
sudo apt-get install python3-pyqt5
Otherwise you'd have to compile PyQt (and potentially Qt) by hand, which is cumbersome.
Upvotes: 68