1

I am trying to install PyQt4 on ubuntu 22.04, because a specific software need python2 and PyQt4:

  1. install python2
sudo apt install python
  1. link python2 to python

Now, python -v is

Python 2.7.18 (default, Jul  1 2022, 10:30:50)
[GCC 11.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

I think the python2 is sucessful installed.

  1. I follow this link to install PyQt4: Pyqt4 on Ubuntu 20.04 install
wget http://archive.ubuntu.com/ubuntu/pool/universe/q/qt-assistant-compat/libqtassistantclient4_4.6.3-7build1_amd64.deb
sudo apt-get install ./libqtassistantclient4_4.6.3-7build1_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/p/python-qt4/python-qt4_4.12.1+dfsg-2_amd64.deb
sudo apt-get install ./python-qt4_4.12.1+dfsg-2_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/p/python-pyaudio/python-pyaudio_0.2.11-1build2_amd64.deb
sudo apt-get install ./python-pyaudio_0.2.11-1build2_amd64.deb

It failed at sudo apt-get install ./python-qt4_4.12.1+dfsg-2_amd64.deb

The following packages have unmet dependencies:
 python-qt4 : Depends: python (< 2.8) but it is not installable
              Depends: python (>= 2.7~) but it is not installable
              Depends: python:any (< 2.8) but it is not installable
              Depends: python:any (>= 2.7.5-5~) but it is not installable
              Depends: sip-api-12.2 but it is not installable

My questions is:

Its seem that python 2.7.18 is sucessful installed, why the depends is still not installable

how to install depends sip-api-12.2? Its seems hard for ubuntu 22.04?

zhang
  • 167

1 Answers1

1

I also was needed to install pyqt4 on Ubuntu 22.04. And I'm too tried to install it with .deb packages, and it didn't work.

But I managed to install PyQt4 with source code.

Disclaimer: I do not gurantee that it will work without some problems, or maybe you can encounter some issues with your system where it is using python in any case. In my case it was all good.

I assume you already have python2.7 installed with command: sudo apt install python2

1. First of all I installed qt4 (But I don't figured out completely, did I was need it to install)

sudo add-apt-repository ppa:ubuntuhandbook1/ppa
sudo apt update
sudo apt install qt4-default

and other packages, that are started with qt4- Maybe you can use ppa:rock-core/qt4 instead of ppa:ubuntuhandbook1/ppa

2. To delete broken installed .deb packages I used command:

sudo apt -f install

3. After that I set alias for python 2.7 in ~/.bashrc file:

alias python=/usr/bin/python2.7 в ~/.bashrc

Then save it:

source ~/.bashrc

4. Also I set python2.7 as default python by commands:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --config python

But I don't think it is necessary

5. Now let's get to PyQt4. Download source code for sip: sip or older version: sip_older

Unzip to separate directory and run commands to install it:

python configure.py
make
sudo make install

6. Download source code for PyQt4: PyQt4

Unzip to separate directory too and run same commands to install it:

python configure.py
make
sudo make install

After that I could use import PyQt4 in Python files.

Also I saw some commands to install PyQt4 from source code like: python configure-ng.py

But I encountered some problems with it (а QtCore Module Error: Unable to create the C++ cod), that leading to

Please, comment some lines in configure-ng.py: argv.append('-B') argv.append('Qt_5_0_0')

But that leads me to issues with make command (pyqt4 make qpycore_post_init.cpp:(.text+0x0): multiple definition). So I think you need to install it with commands:

python configure.py
make
sudo make install

as I mentioned above.