How to get PyQt5 for Python2 on Ubuntu 20.04

6,114

Solution 1

attempting to install Bionic's python2/pyqt5 packages on 20.04 breaks because the 18.04 python-pyqt5 requires qtbase-abi-5-9-5 which causes significant conflicts on 20.04 if you try to install it. however, that package provides nothing necessary. therefore, provide your own, to fulfill that dependency.

here's the solution (high level):

  • install this qtbase-api-fake deb package to fulfill the qtbase-abi requirement. the package is literally nothing but an empty file.
  • add bionic back into your apt repositories
  • install python-pyqt5.qtwebkit (which will install python-pyqt5)

detailed solution:

  1. build the qtbase-abi-fake package and install it. you can simply copy and paste this into a terminal once you're comfortable i have done nothing nefarious:
# create the package structure:
cd /tmp
mkdir qtbase-abi-fake
mkdir -p qtbase-abi-fake/DEBIAN
mkdir -p qtbase-abi-fake/usr/lib/qtbase-abi-fake
touch qtbase-abi-fake/usr/lib/qtbase-abi-fake/nothing.txt

# create the deb control file (the guts):
cat <<_EOF > qtbase-abi-fake/DEBIAN/control
Package: qtbase-abi-fake
Version: 5.9.5
Section: custom
Priority: optional
Architecture: all
Essential: no
Installed-Size: 1024
Maintainer: atlas
Description: Fakes out python-pyqt5 from Ubuntu 18.04 to work on 20.04  
Provides: qtbase-abi-5-9-5
_EOF

# build the qtbase-abi-fake.deb file:
dpkg-deb --build qtbase-abi-fake

# install your newly created deb file:
sudo dpkg -i qtbase-abi-fake.deb
  1. add bionic to apt repos:
echo 'deb http://us.archive.ubuntu.com/ubuntu/ bionic universe multiverse' | sudo tee /etc/apt/sources.list.d/bionic-helper.list
  1. install the necessary libraries (for vivisect, you want python-pyqt5.qtwebkit):
sudo apt update
sudo apt install python-pyqt5.qtwebkit

that should get you a working python2 pyqt5 environment with qtwebkit.

this fix makes Bionic 18.04's python-pyqt5 work on Focal 20.04, so all the packages that depend on it (like qtwebkit) work as well.

once you build this, you can share it with your friends. i would have provided the deb file here, but there's no easy way to do it. plus this way, you get to see what's going on at each step.

hope this helps! @

Solution 2

Best temporary solution so far (with caveat):

$ wget http://us.archive.ubuntu.com/ubuntu/pool/universe/p/pyqt5/python-pyqt5_5.10.1+dfsg-1ubuntu2_amd64.deb
$ wget http://us.archive.ubuntu.com/ubuntu/pool/universe/p/pyqt5/python-pyqt5.qtwebkit_5.10.1+dfsg-1ubuntu2_amd64.deb
$ dpkg -i --force-depends python-pyqt5_5.10.1+dfsg-1ubuntu2_amd64.deb
$ dpkg -i python-pyqt5.qtwebkit_5.10.1+dfsg-1ubuntu2_amd64.deb

This will allow my app to work. However, each time I apt install or apt upgrade, it complains about the broken dependency and refuses to install or update until I resolve it. Probably the best answer would be to create a .deb package that provides qtbase-abi-5-9-5 which is what the broken dependency is. This appears to be Ubuntu's way of making Python2.7 QT hooks not work.

Anyone have ideas on a better solution (until the app is ported to Py3)? Is there a way to make apt work properly, while ignoring this particular broken dependency?

Share:
6,114
kurios
Author by

kurios

Updated on September 18, 2022

Comments

  • kurios
    kurios over 1 year

    I have a critical PyQt5 application which is still in the migration to Python3 phases.
    K/Ubuntu 20.04 has removed the required packaging to install PyQt5 for Python 2.7. I understand the importance of these apps to migrate to Py3, but I'm the user who still needs the apps. I'm glad Ubuntu has made Python 2.7 still available, even if they've made Py3 the default. But I need to have continued access to this and couple other apps, and I would like to be able to upgrade all my systems to Ubuntu 20.04. Expressly, I need PyQt5 and QtWebKit (yes, I know QtWebKit was also deprecated).

    I am trying not to make my machine too much of a mess in the process. Would like an elegant and simple method.

    So far, I've tried numerous incantations of pip install (although I will humbly accept if someone is able to make it work through Pip)

    I've added in previous deb repos from previous Ubuntu versions, Eoan and Bionic, and had no luck so far. I don't doubt there is a way to make this approach successful... but I haven't found it yet. I'd love for some help.

    I have many colleagues who also use this software. Best answer for me would be one I could easily point others to and have them not need to be a master of the Linux universe. Preferably not "download source and start compiling".

    Thanks in advance!

  • kurios
    kurios almost 4 years
    Thanks! This worked great! And on the machines I had already manually installed python-pyqt5 using dgpk, installing qtbase-abi-fake resolved my issues and I'm able to install/upgrade software again. :) Now, just need the Vivisect maintainers to complete the Py3 migration!
  • atlas
    atlas almost 4 years
    yeah, i know. we're working on it :) we finally git vivisect into PyPi, we're merging in a couple massive architecture and analysis branches, and then Py3 is top priority.
  • shmu
    shmu about 3 years
    Thanks. Now I can install HPLIP 3.21.2 on Ubuntu 20.04.2
  • alexg
    alexg about 2 years
    And I installed HPLIP 3.22.2 on Ubuntu 20.04.4! Thanks!