PYQT4 - How do I compile and import a qrc file into my program?

Thomas picture Thomas · Apr 7, 2013 · Viewed 42.7k times · Source

I'm having trouble importing a resource file. I'm using pyqt4 with monkey studio and I am trying to import a png image. When I run the program I get an import error like

ImportError: No module named icon_rc

I know that I have to compile it using pyrcc4 but I don't understand how to do this can anybody help please. It would be very helpful to have an answer that fully explains how to compile the resource file so I can import it.

Answer

Thomas picture Thomas · Apr 8, 2013

Open cmd (or terminal on *nix) and run

pyrcc4 -py3 F:\computing\Payrollv22\icon.qrc -o icon_rc.py

It compiled the file successfully and I was able to import the py file into my project and run it with no problem.