A
A
Alexey Yarkov2016-11-26 14:17:52
Python
Alexey Yarkov, 2016-11-26 14:17:52

How to automatically compile resource file in pyqt5?

Hello. And again I am with stupid questions about Python and PyQt5.
I create the main form and push the icons into the icons.qrc resource file.
Then mainwindow.ui is compiled into a py file with the command:

pyuic5 -o mainwindow.py --resource-suffix=_rc mainwindow.ui
.
And import res_rc is appended to the end of the file.
On Qt4, this file (res_rc.py) was normally assembled for me using the command: pyrcc4 -o res_rc.py icons.qrc
But in Qt5, an error occurs:
$ pyrcc5 -o res_rc.py icons.qrc
Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3/dist-packages/PyQt5/pyrcc_main.py", line 23, in <module>
    from .pyrcc import *
RuntimeError: the sip module implements API v11.0 but the PyQt5.pyrcc module requires API v11.3

What is it? I understand the problem in sip. But damn, what the hell?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RUNAMAN, 2018-06-15
@RUNAMAN

Update PyQt to the latest version.
1. In the editor, add resources, and save in the file xres.qrc
2. Convert the resource source
pyrcc5 -o xres_rs.py xres.qrc
3. Hemming the use in the main program
import core.forms.resource.xres_rs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question