RuntimeError: the PyQt5.QtCore module failed to register with the sip module

Phil Thompson phil at riverbankcomputing.com
Sun Jul 17 14:09:21 BST 2022


On 14/07/2022 14:04, Edward A. Pier wrote:
> I have C++ code that depends on Qt5 that I wrap into Python using sip.
> I am porting code that worked under Ubuntu 20.04 (sip 4.19.21, PyQt5
> 5.14.1) to run under Ubuntu 22.04 (sip 6.5.1, PyQt5 5.15.6). Now when
> I import the resulting Python module I get the error in the subject
> line:
> 
> RuntimeError: the PyQt5.QtCore module failed to register with the sip 
> module
> 
> I traced this to the generated file siplib.c in the
> sip_api_export_module function. This function tries to load required
> modules, of which PyQt5.QtCore is the first. It calls
> PyImport_ImportModule and then tries to find the module in a linked
> list kept in the moduleList variable. The problem is that on the first
> call to sip_api_export_module, moduleList=NULL, i.e. the list is
> empty, as it only gets updated at the bottom of sip_api_export_module.
> 
> So I'm a bit stumped how this could work, unless the first module for
> which sip_api_export_module is called does not have dependencies, or
> sip_api_export_module is called for those dependencies first. I've
> read through the pyproject.toml documentation, but I didn't see any
> way to make either of these things happen.

PyImport_ImportModule of QtCore will call QtCore's PyInit_QtCore 
function which itself calls sip_api_export_module and adds QtCore to 
moduleList.

It sounds like something called QtCore is being successfully imported 
but it's not the QtCore extension module.

> Let me know what additional information might help get to the bottom of 
> this.

The pyproject.toml file might help.

Phil


More information about the PyQt mailing list