30

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 ?

2
  • pip install pyqt5 worked just fine
    – sureshvv
    Aug 28, 2018 at 9:59
  • The install process went ok. But got runtime error QtCore.so: undefined symbol: PySlice_AdjustIndices
    – sureshvv
    Aug 28, 2018 at 10:14

4 Answers 4

66

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.

3
26

Well I documented the steps for Installing pyqt5 with qt designer and code generation here: https://gist.github.com/1dcd57542bdaf3c9d1b0dd526ccd44ff

Installation

pip3 install --user pyqt5  
sudo apt-get install python3-pyqt5  
sudo apt-get install pyqt5-dev-tools
sudo apt-get install qttools5-dev-tools

Configuring to run from terminal

$ 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

Code Generation

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

[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

2
  • pip3 install --user pyqt5 will most likely throw Could not find a version that satisfies the requirement sip>=4.19.1. I'm installing it from a fresh Linux installation. Sep 16, 2018 at 18:33
  • where are you putting the uic.py file?
    – markling
    Apr 12, 2019 at 0:46
0
  • sudo apt-get install python3-pip
  • sudo pip3 install PyQt5
0

How to install PyQt5 in Python3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.