I have resources.qrc compiled to resources.py using the following batch file:

@echo off
call "C:\Program Files\QGIS 3.0\bin\o4w_env.bat"
call "C:\Program Files\QGIS 3.0\bin\qt5_env.bat"
call "C:\Program Files\QGIS 3.0\bin\py3_env.bat"

@echo on
pyrcc5 -o resources.py resources.qrc

I import resources at the beginning of the code but i get the following error:

ModuleNotFoundError: No module named 'resources'

I tried editing the .ui file as explained here: QGIS plugin: Problems importing resources (resources_rc) file - plugin doesn't load - PATH problems? But I don't have the exact same lines as mentioned instead of:

<resources>
  <include location="resources.qrc"/>
</resources>

I have:

<resources/>
 <connections/>
</ui>

Here is the content of the folder: enter image description here Does somebody have a clue what is wrong?

  • Post the full code of the .bat file, and a screenshot of the contents of the folder. – HeikkiVesanto Mar 13 at 11:29
  • @HeikkiVesanto Thank you, added a screenshot, the bat file is in it's full version however – Carmel Han Mar 13 at 12:22
  • Try with from resources import * – Germán Carrillo Mar 13 at 12:50
  • I'm not answering your question. I personally stopped using resources files in all my plugins. I saw the same in other plugins. Using the filepath on the file system is working well to load icons, images or whatever. We don't have to recompile anymore this file. – Gustry Mar 13 at 13:22
  • Can you try the bat script from: gis.stackexchange.com/questions/260743/… That works for me. – HeikkiVesanto Mar 13 at 13:37

As your ParcelCapture.py and resources.py are in same directory you can use relative path like this from .resources import * to import resources module into your ParcelCapture.py.
Hope this answers your question.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.