3

I have read this post: Can't compile plugin builder plugin in QGIS 2.4 (Windows)

But I couldn't resolve my problem.

I have already seen this post, looking for help. I can execute:

pyrcc4 -o resources_rc.py resources.qrc

But when I want to open my plugin made by Plugin Builder, it displays an error, saying that it is "broken".

enter image description here

3
  • Did you try using the make command for your plugin and then restarting QGIS?
    – Joseph
    Mar 31, 2016 at 13:21
  • My OSGeo4W Shell doesn't recognise that command, that is why I am so dissapointed... :( I don't know what to do about that. I have tried to execute pb_tool but in my windows shell, I don't think it is going to recognise the code in the examples of the help documentation about pb_tool
    – user64823
    Mar 31, 2016 at 13:25
  • 1
    Strange, maybe try reinstalling QGIS again using the OSGeo4W Network Installer? I recently had to reinstall QGIS (about 3 weeks ago) and the make method is still recognised.
    – Joseph
    Mar 31, 2016 at 13:36

1 Answer 1

3

It seems your plugin doesn't have a metadata.txt file, could you have a look at the plugin folder to check if such file is present?

Make sure all your plugin files are inside your plugin folder, which in turn should be inside python/plugins/ folder, like this:

qgis2/
...python/
......plugins/
.........NPlugin/
............metadata.txt
............__init_.py
............icon.png
............(and all other files)

Sometimes, one can make a mistake and create an extra folder while choosing the directory to save the plugin, like this:

qgis2/
...python/
......plugins/
.........NPlugin/
............NPlugin/
...............metadata.txt
...............__init_.py
...............icon.png
...............(and all other files)

Note the double NPlugin folder (python/plugins/NPlugin/Nplugin/...), which will make QGIS not to load the plugin. If that's your case, just leave a single NPlugin folder, from which QGIS can access all plugin files (such as in the first directory structure I mentioned).

If, on the contrary, your directory structure is fine, your plugin is missing a metadata file. Create a new file metadata.txt inside you plugin folder, containing information like:

# This file contains metadata for your plugin.         
[general]
name=My Plugin
qgisMinimumVersion=2.0
description=My plugin does a lot of things
version=0.1
author=Me
[email protected]

about=Plugin to do a lot of things

tracker=http://www.mycompany.co/tracker
repository=http://www.mycompany.co/git

# Tags are comma separated with spaces allowed
tags=GIS,Raster

homepage=http://www.mycompany.co/
category=Plugins
icon=icon.png
# experimental flag
experimental=True

# deprecated flag (applies to the whole plugin, not just a single version)
deprecated=False

Restart QGIS (or reload your plugin) and you should now get your plugin loaded.

5
  • +1, great answer! I will be writing a plugin soon so will definitely need to keep this in mind!
    – Joseph
    Mar 31, 2016 at 14:00
  • 2
    Just tried to create a test plugin and it happened to me, I created a double folder for my plugin, so I got the same error. Let's hope that solves the problem. Mar 31, 2016 at 14:02
  • 1
    I have changed the folder, and made the resources_rc.py. Metadata is available. Then, I closed QGIS and opened again. I got this error again: No module named resources
    – user64823
    Mar 31, 2016 at 14:30
  • 2
    Ok, that's another question. Your plugin (as it was created via Plugin Builder) expects the resources file to be named 'resources.py'. Try with such name. Mar 31, 2016 at 14:50
  • I used pyrcc4 -o resources.py resources.qrc and it worked. Thanks very much to everybody !!!
    – user64823
    Apr 1, 2016 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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