Source

ImportError: No module named resource_rc

Hi there folks. How are you? Recently I was using Qt Designer to design a GUI for one of my apps. After doing all the designing I saved my ui file and ran pyuic4 over it. Everything worked fine and I had a Python ui file created in my system. But when I tried to run the Python ui file I was confronted with an error. It read something like this:

ImportError: No module named resource_rc

So what was the problem? After doing some research I saw that a resource_rc file was referenced in my Python ui file but I was not able to find that resource_rc file anywhere in my system. But there was a .qrc file which I had not noticed before.

After searching a little I came to know that the .qrc file was a resource file of the Qt Designer. At that moment I came to know what the problem was. I had not converted the .qrc file into Python. The problem was hard to find because there was not a single helpful error which clearly stated that I had not converted the resource file into Python. I solved the problem by running this command:

pyrcc4 -o App/ui/resources_rc.py App/resources.qrc

The above command runs the PyQt resource compiler which was already installed with PyQt4 on my Ubuntu laptop. pyrcc4 then compiles the resource file into Python which can easily be imported and used in Python. That solution solved my problem.

So that was it. I hope that this post was helpful for you. In order to stay updated with my future posts then don’t forget to follow me on Twitter, Facebook and this blog. Stay tuned for my next post which is going to be a book giveaway. Goodbye!

Newsletter

×

If you liked what you read then I am sure you will enjoy a newsletter of the content I create. I send it out every other month. It contains new stuff that I make, links I find interesting on the web, and occasional discount coupons for my book. Join the 5000+ other people who receive my newsletter:

I send out the newsletter once every other month. No spam, I promise + you can unsubscribe at anytime

✍️ Comments

Rodolfo Torres

Thank you so much for your help, this worked wonderfully!

Yasoob
In reply to Rodolfo Torres

I am happy that it worked out for you! :)

Pytha

Great. Thanks for putting the solution out there. It was helpful

Josh Martin

Awesome. This was the first result and a perfect match for my issue. Docs are hard.

Omonbude

please can you help me am getting this error after running your code pyrcc4: File does not exist ‘App/resources.qrc’

am using windows though

joecat808

Helped me so much. Thank you!!!

Mimouni Dali

Thanks finaly it is working :'(

Yasoob
In reply to Mimouni Dali

I am glad to hear that :)

Say something

Send me an email when someone comments on this post.

Thank you!

Your comment has been submitted and will be published once it has been approved. 😊

OK