3

I'm currently using Ubuntu 18.04 LTS.

I'm trying to install a program that need PyQt4 and QtWebKit, so a manual installation is necessary as QtWebKit have been excluded from PyQt4.

I downloaded sip 4.19.12 (with 4.19.14 installation of PyQt4 fails) and PyQt4 4.12.13

I ran a virtualenv, made sure it was working as intended and tried installing sip, which works:

$ python configure.py
$ make
$ make install

Then I proceed with the same with PyQt4, with no errors.

When I try to run my program .py, it gives the following error:

$ python RNAEditor.py
Traceback (most recent call last):
File "RNAEditor.py", line 9, in <module>
from Helper import Helper, Parameters
File "/home/bioinfo/Documentos/Ferramentas_RNAEditor/RNAEDITOR_ch/Helper.py", line 13, in <module>
from PyQt4 import QtCore
ImportError: No module named sip

$ sudo python RNAEditor.py 
Traceback (most recent call last):
File "RNAEditor.py", line 9, in <module>
from Helper import Helper, Parameters
File "/home/bioinfo/Documentos/Ferramentas_RNAEditor/RNAEDITOR_ch/Helper.py", line 13, in <module>
from PyQt4 import QtCore
ImportError: No module named PyQt4

I'm sure that my virtual env does have sip and PyQt4, as importing both within virtualenv/python gives no error too.

$ python
>>> import PyQt4
>>> import sip
>>> from PyQt4 import QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named sip

Any ideas on how to set PyQt4 and sip with a manual installation, or why it is not working as intended?

Gabriel G.
  • 555
  • 1
  • 3
  • 13
  • What version of python are you using? – smitty_werbenjagermanjensen Mar 29 '19 at 20:04
  • 1
    Run [this - replacing `key = sip`](https://stackoverflow.com/a/55407517/7414759) then [edit] your Question to show the output. – stovfl Mar 29 '19 at 22:37
  • In the Python prompt, can you show the output of `PyQT4.__path__` and `sip.__path__` (if you get errors about a non-existent attribute, try with `.__file__` instead). If one of those is local to your current working directory, than that's where your problem is. – 9769953 Mar 30 '19 at 20:08
  • Please understand that **sip** tag is for rfc3261. see [link](https://stackoverflow.com/questions/tagged/sip) – AymericM Sep 23 '20 at 12:55

2 Answers2

5

PyQt started from version 4.12.2 needs private sip module called PyQt4.sip (see file NEWS in PyQt 4 source folder) So you should configure sip using this command: python configure.py --sip-module PyQt4.sip After sip is built, you should copy file sip.pyd to PyQt4 python directory - by default it is c:\python27\Lib\site-packages\PyQt4

John Govage
  • 139
  • 1
  • 3
  • 3
0

I got it to work with specific SIP and PyQt4 versions and running inside a virtualenv. I have no idea what happens, but it seems that in Ubuntu 18.04 something happens with the last versions of PyQt4 and SIP and they do not work as intented, but they do work in Ubuntu 16.04 (tested). The code that worked in Ubuntu 18.04 is:

PYQT4 4.12.1 and sip 4.19.12

sudo apt-get install python-pip python2.7-dev libxext-dev python-qt4 qt4-dev-tools build-essential

pip install virtualenv


virtualenv PROJECTNAME
source PROJECTNAME/bin/activate


cd SIP_SOURCE_DIRECTORY
python configure.py
make
make install

cd PYQT4_SOURCE_DIRECTORY
python configure.py
make
make install

Then you have your virtualenv where QtWebKit is supported, which is important for many applications

Gabriel G.
  • 555
  • 1
  • 3
  • 13