1

I have an GUI application, which is quite big.I have it in Python 2.7. Since Python 2 is no longer being updated, I converted my application to Python 3.8 using 2to3 module. I am facing this problem and have no idea how to solve it. I referred some of the similar problems but did not get anywhere. I have the following error:

QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) TypeError: qRegisterResourceData(int, bytes, bytes, bytes): argument 2 has unexpected type 'str'

What should I do to get pass this issue?

Sash7
  • 73
  • 1
  • 11

1 Answers1

3

Resource files on PyQt are actually python scripts with base64 encoded data.

When porting to newer systems (both python 3 and Qt5) requires proper updating of those files.

Generally, it can be done by calling again the pyrcc command (pyrcc5 or pyrcc5.exe if both Qt versions are installed), but they can be manually ported, considering the following aspects:

  • the import statement has obviously be modified to PyQt5;
  • all variables (qt_resource_data and qt_resource_name) are bytes literals and require the b'...' prefix;

from PyQt5 import QtCore

qt_resource_data = b"\
    -- raw data --
"

qt_resource_name = b"\
    -- raw data --
"
musicamante
  • 41,230
  • 6
  • 33
  • 58
  • I would have upvoted your answer, but could not because of my reputation points. Thank you very much! – Sash7 Feb 02 '21 at 16:08
  • @Sash7 don't worry, the important thing is that it's marked as accepted. Keep following and interacting on SO and you'll easily get [more reputation](https://stackoverflow.com/help/whats-reputation). – musicamante Feb 02 '21 at 16:10