Skip to content

Instantly share code, notes, and snippets.

Last active February 23, 2024 04:50
Star You must be signed in to star a gist
Save r00tdaemon/1dcd57542bdaf3c9d1b0dd526ccd44ff to your computer and use it in GitHub Desktop.
Install PyQt5 on Ubuntu with python3. Steps to set up PyQt5 (ubuntu). With python code generation


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


Write the following in /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf


Code Generation

Create file.


import subprocess
import sys

child = subprocess.Popen(['pyuic5' ,'-x',sys.argv[1]],stdout=subprocess.PIPE)


$ chmod +x

Create a symlink:

$ sudo ln "/usr/lib/x86_64-linux-gnu/qt5/bin/uic"

Desktop Entry

[Desktop Entry]
Name=Qt5 Designer

Name[en_US]=Qt5 Designer

[Desktop Action NewWindow]
Name=Open a New Window

save in ~/.local/share/application with .desktop extension

Copy link

I'm also getting "python egg_info" failed with error code 1 ..." . Did anyone get a fix for this yet? I tried "pip3 install --user pyqt5==5.14" as mentioned above but same problem?

Copy link

Hi @SteveF161,
I don't know how I finally got passed the error as it was some time ago.
But I can show the output I get now as it might give you a clue:

$ pip3 install --user PyQt5
Requirement already satisfied: PyQt5 in /home/liron/.local/lib/python3.6/site-packages (5.14.2)
Requirement already satisfied: PyQt5-sip<13,>=12.7 in /home/liron/.local/lib/python3.6/site-packages (from PyQt5) (12.7.2)
WARNING: You are using pip version 20.1; however, version 20.2.2 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.

Copy link

Hello @SteveF161 I can confirm @LionOpeter 's suggestion to update pip3
pip3 install --upgrade pip
worked for me on Ubuntu 18.04 LTS

Copy link

I got this error, someone can help me:

/usr/bin/python3.8 /home/dung/PycharmProjects/detai/
QObject::moveToThread: Current thread (0x19ebfd0) is not the object's thread (0x20abd70).
Cannot move to target thread (0x19ebfd0)

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/dung/.local/lib/python3.8/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl.

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

Copy link

chrswp commented Jul 17, 2021

Crystal clear instruction how to install PyQt5. Works like a charm!

Thanks for the instruction.

Copy link

smnlin commented Sep 7, 2022

This still works on ubuntu 20.04!!!
Thank you so much!!!

Copy link

Thank you, you helped me a lot

Copy link

Hi @ujjwal96 ,

I am trying to install a ML package iLearnPlus
I made a separate conda environment on Ubuntu 22-04 and followed all the instructions while installing PyQt5 which you have recommended here.
I am still getting an error:

Traceback (most recent call last):
  File "", line 5, in <module>
    from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget, QDesktopWidget, QLabel, QHBoxLayout, QMessageBox, QAction, QFileDialog)
ImportError: /home/amit/miniconda3/envs/ilearn/lib/python3.8/site-packages/PyQt5/ undefined symbol: _ZdlPvm, version Qt_5

Kindly help. Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment