borysiasty / plugin_reloader

QGIS plugin: Reloads a chosen plugin in one click (only useful for Python Plugin Developers)
GNU General Public License v3.0
19 stars 17 forks source link

Processing Provider plugin to reloadable #20

Closed ghtmtt closed 5 years ago

ghtmtt commented 5 years ago

Steps to reproduce the error are just straightforward: just build a simple plugin with the plugin builder as processing provider plugin.

Then, reloading the plugin causes this weird error:

Couldn't load plugin 'medsens' 

ImportError: attempted relative import with no known parent package 
Traceback (most recent call last):
  File "/home/matteo/lavori/QGIS/build-qgis3-master/output/python/qgis/utils.py", line 309, in loadPlugin
    __import__(packageName)
  File "/home/matteo/lavori/QGIS/build-qgis3-master/output/python/qgis/utils.py", line 672, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/matteo/.local/share/QGIS/QGIS3/profiles/matteo/python/plugins/medsens/medsens.py", line 38, in 
    from .medsens_provider import medSensProvider
  File "/home/matteo/lavori/QGIS/build-qgis3-master/output/python/qgis/utils.py", line 672, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: attempted relative import with no known parent package

BTW: closing QGIS, changing something in the plugin and reopening QGIS is not giving any error.

Tested with QGIS master (3.5) on Debian Sid and last plugin reloader version 0.7.5

borysiasty commented 5 years ago

Hi, thanks for the report! Reloading Python modules is tricky and I haven't found any solution for Processing plugins yet. Maybe reloading the whole Processing is the way to go. I'll try to continue working on it next year, but don't expect any solution soon, please...

ghtmtt commented 5 years ago

ok fine to hear that this problem is not related to my error ;)

thanks!

ghtmtt commented 5 years ago

Hi Borys... just to put more entropy in the system.. some Processing plugins are correctly reloaded other not.

e.g. https://plugins.qgis.org/plugins/qproto/ (having it as a local git and also by downloading it) is not giving any problems, while creating a new Processing plugin from scratch gives the import error of above even if you don't touch the code

borysiasty commented 5 years ago

Good catch, thanks! I'll have to look at it deeper.

kobben commented 5 years ago

Got the same problem of processing plugin not reloading. In a email conversation found that yquenach@itlink.fr concluded the problem apparently occurs if the plugin python file has the same name as its containing folder [which is normally the case, because that's the way that the Plugin Builder delivers its output. Tested and can confirm. If you eg rename the folder holdeing the processing plugin files from plugin_name to my_plugin_name , the reloading works fine...

borysiasty commented 5 years ago

Ah thanks! So the problem is deeper in the Python import system and not in the plugin reloader. You'll get the same error after upgrading the plugin or just disabling and enabling it back in the manager.

Ideally it should be fixed in QGIS core, but after some googling it doesn't looks trivial and personally I won't have time to investigate it further. So maybe it would be easier to change the Plugin Builder to name the module (file) differently from the package (directory). Would you mind to propose it to Gary in the https://github.com/g-sherman/Qgis-Plugin-Builder/issues ?