Bug report #10045

Error upon upgrading Processing (possibly other complex plugins)

Added by Paolo Cavallini about 10 years ago. Updated over 6 years ago.

Status:Closed
Priority:Normal
Assignee:Borys Jurgiel
Category:Plugin Manager
Affected QGIS version:2.2.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:18526

Description

Upon upgrading Processing, we get an error. However, restarting QGIS seems to cure it.

According to Alex Bruy, it is possible that plugin manager can't correctly reload plugin after upgrade.

===
Impossibile caricare il plugin 'processing' da
['/usr/share/qgis/python/plugins/processing', '/usr/share/qgis/python',
'/home/paolo/Desktop/qgis_analisi_pontedera/qgis2/python',
'/home/paolo/Desktop/qgis_analisi_pontedera/qgis2/python/plugins',
'/usr/share/qgis/python/plugins', '/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode',
'/usr/share/qgis/python/plugins/fTools/tools']

Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 182, in
loadPlugin
import(packageName)
File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 453, in
import
mod = _builtin_import(name, globals, locals, fromlist, level)
File
"/home/paolo/Desktop/qgis_analisi_pontedera/qgis2/python/plugins/processing/
_init__.py",
line 29, in
from processing.tools.general import *
File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 453, in
_import
mod = _builtin_import(name, globals, locals, fromlist, level)
File
"/home/paolo/Desktop/qgis_analisi_pontedera/qgis2/python/plugins/processing/tools/general.py",
line 29, in
from processing.core.Processing import Processing
File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 453, in
_import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/share/qgis/python/plugins/processing/core/Processing.py",
line 45, in
from processing.modeler.ModelerAlgorithmProvider import \\
File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 453, in
_import
mod = _builtin_import(name, globals, locals, fromlist, level)
File
"/usr/share/qgis/python/plugins/processing/modeler/ModelerAlgorithmProvider.py",
line 39, in
from processing.modeler.EditModelAction import EditModelAction
File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 453, in
_import
mod = _builtin_import(name, globals, locals, fromlist, level)
File
"/usr/share/qgis/python/plugins/processing/modeler/EditModelAction.py",
line 30, in
from processing.modeler.ModelerDialog import ModelerDialog
File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 453, in
_import
mod = _builtin_import(name, globals, locals, fromlist, level)
File
"/usr/share/qgis/python/plugins/processing/modeler/ModelerDialog.py",
line 35, in
from processing.gui.ParametersDialog import ParametersDialog
File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 453, in
_import
mod = _builtin_import(name, globals, locals, fromlist, level)
File
"/home/paolo/Desktop/qgis_analisi_pontedera/qgis2/python/plugins/processing/gui/ParametersDialog.py",
line 29, in
from processing.gui.ParametersPanel import ParametersPanel
File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 453, in
_import
mod = _builtin_import(name, globals, locals, fromlist, level)
File
"/home/paolo/Desktop/qgis_analisi_pontedera/qgis2/python/plugins/processing/gui/ParametersPanel.py",
line 65, in
from processing.parameters.ParameterMultipleExternalInput import
ParameterMultipleExternalInput
File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 453, in
_import
mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named ParameterMultipleExternalInput

History

#1 Updated by Borys Jurgiel about 10 years ago

  • Category changed from Plugin Manager to Python plugins

Yes, QGIS doesn't reload correctly some complex plugins, however, I believe it should be fixed on the plugin side.

To reload a plugin completely, QGIS needs to unload all its modules (it doesn't work if you just import already loaded module again). We've overwritten the Python's import statement, so it's able to register all recognized modules related to a given plugin. Later they are being unloaded when reloading the plugin. See `qgis.utils._plugin_modules`. But it only can work if the module import contains the plugin name, like `from myPlugin.foo import bar`. In case the plugin does just `from foo import bar`, the import statement doesn't know to which plugin the module should be assigned. As a result, the module is not registered and not unloaded when reloading its plugin.

The only solution on the QGIS side I can imagine is to check the path of every imported module and include it to the _plugin_modules if it's located inside one of the plugins. But iterating over all plugin directories at every import in Python doesn't look too elegant and it may even affect the overall QGIS performance (I didn't tested it). I'm not sure if it's reasonable to risk the performance for the rare case of a complex plugin reload. Instead, plugin authors could just always start the import paths with the plugin module (maybe we even unnecessarily add all the plugin directories to the Python paths? Alternatively, the affected modules can be unloaded in the Plugin.unload() implementations.

Alex, please let me know if it was the reason and changing the imports helps.

#2 Updated by Alexander Bruy about 10 years ago

In Processing case all imports already include plugin name in imports, for example

from processing.gui.OutputSelectionPanel import OutputSelectionPanel
from processing.gui.MultipleFileInputPanel import MultipleFileInputPanel

I'll check all Processing files, but I'm pretty sure that all imports contain plugin name.

Maybe this is caused by another issue? E.g. there is an version 1.0 of plugin installed. New version 1.1 is out and contains one or several new modules (or some unused modules were removed). Will this new modules picked and loaded correctly?

In Paolo's case error appeared after Processing update, when new modules were added. Similar error also appears when some modules were removed.

#3 Updated by Borys Jurgiel about 10 years ago

Please let me know next time when the bug is reproductable.

#4 Updated by Borys Jurgiel about 10 years ago

Has anybody observed this problem with other plugins?

#5 Updated by robert kalasek about 10 years ago

i've just triede to upgrade the processing plugin ...
-- didn't have any problems on win 7 + qgis 2.2.0 (c3a2817)
but ... on mac (os x 10.9.2 + qgis 2.2.0) i just had a similar problem. the interesting thing about that is, that i had the same problem a week ago and was not able to reinstall processing plugin after getting the error message last week. had to reinstall qgis !
this time: the same errormessage followed by a "processing plugin was installed successfully"
seemed suspicious --> so i tried to run a processing tool: a soon as i clicked dissolve (processing toolbox / vector geometry tools) ... i got the following error:

-----------------------------------
An error has occured while executing Python code:

Traceback (most recent call last):
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/gui/ProcessingToolbox.py", line 152, in executeAlgorithm
alg = alg.getCopy()
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/core/GeoAlgorithm.py", line 97, in getCopy
newone = copy.copy(self)
AttributeError: 'NoneType' object has no attribute 'copy'

Python version:
2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]

QGIS version:
2.2.0-Valmiera Valmiera,

Python path: ['/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing', '/Applications/QGIS.app/Contents/MacOS/../Resources/python', u'/Users/robertkalasek15/.qgis2/python', u'/Users/robertkalasek15/.qgis2/python/plugins', '/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins', '/Library/Frameworks/SQLite3.framework/Versions/B/Python/2.7', '/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7', '/Library/Python/2.7/site-packages/numpy-override', '/Library/Python/2.7/site-packages/matplotlib-override', '/Library/Frameworks/GDAL.framework/Versions/1.10/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages', '/Applications/QGIS.app/Contents/Resources/python/plugins/fTools/tools', '/Users/robertkalasek15/Documents/_Projekte/qgis_schulung_at_gb2_20']
--------------------

#6 Updated by Antonio Locandro almost 10 years ago

Got this issue today

Couldn't load plugin 'processing' from ['C:/Users/antonio.locandro/.qgis2/python/plugins\\processing', 'C:/OSGeo4W/apps/qgis-dev/./python', 'C:/Users/antonio.locandro/.qgis2/python', 'C:/Users/antonio.locandro/.qgis2/python/plugins', 'C:/OSGeo4W/apps/qgis-dev/./python/plugins', 'C:\\OSGeo4W\\bin\\python27.zip', 'C:\\OSGeo4W\\apps\\Python27\\DLLs', 'C:\\OSGeo4W\\apps\\Python27\\lib', 'C:\\OSGeo4W\\apps\\Python27\\lib\\plat-win', 'C:\\OSGeo4W\\apps\\Python27\\lib\\lib-tk', 'C:\\OSGeo4W\\bin', 'C:\\OSGeo4W\\apps\\Python27', 'C:\\OSGeo4W\\apps\\Python27\\lib\\site-packages', 'C:\\OSGeo4W\\apps\\Python27\\lib\\site-packages\\GDAL-1.11.0-py2.7-win32.egg', 'C:\\OSGeo4W\\apps\\Python27\\lib\\site-packages\\PIL', 'C:\\OSGeo4W\\apps\\Python27\\lib\\site-packages\\win32', 'C:\\OSGeo4W\\apps\\Python27\\lib\\site-packages\\win32\\lib', 'C:\\OSGeo4W\\apps\\Python27\\lib\\site-packages\\Pythonwin', 'C:\\OSGeo4W\\apps\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode', 'C:\\OSGeo4W\\apps\\qgis-dev\\python\\plugins\\fTools\\tools']

Traceback (most recent call last):
File "C:/OSGeo4W/apps/qgis-dev/./python\\qgis\\utils.py", line 182, in loadPlugin
import(packageName)
File "C:/OSGeo4W/apps/qgis-dev/./python\\qgis\\utils.py", line 453, in import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/antonio.locandro/.qgis2/python/plugins\\processing\\
_init__.py", line 29, in
from processing.tools.general import *
File "C:/OSGeo4W/apps/qgis-dev/./python\\qgis\\utils.py", line 453, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/antonio.locandro/.qgis2/python/plugins\\processing\\tools\\general.py", line 29, in
from processing.core.Processing import Processing
File "C:/OSGeo4W/apps/qgis-dev/./python\\qgis\\utils.py", line 453, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/antonio.locandro/.qgis2/python/plugins\\processing\\core\\Processing.py", line 49, in
from processing.algs.qgis.QGISAlgorithmProvider import QGISAlgorithmProvider
File "C:/OSGeo4W/apps/qgis-dev/./python\\qgis\\utils.py", line 453, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named qgis.QGISAlgorithmProvider

Python version:
2.7.4 (default, Apr 6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)]

QGIS version:
2.3.0-Master Master, 70225a3

Python path: ['C:/Users/antonio.locandro/.qgis2/python/plugins\\\\processing', 'C:/OSGeo4W/apps/qgis-dev/./python', u'C:/Users/antonio.locandro/.qgis2/python', u'C:/Users/antonio.locandro/.qgis2/python/plugins', 'C:/OSGeo4W/apps/qgis-dev/./python/plugins', 'C:\\\\OSGeo4W\\\\bin\\\\python27.zip', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\DLLs', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\plat-win', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\lib-tk', 'C:\\\\OSGeo4W\\\\bin', 'C:\\\\OSGeo4W\\\\apps\\\\Python27', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\GDAL-1.11.0-py2.7-win32.egg', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\PIL', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\win32', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\win32\\\\lib', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\Pythonwin', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\wx-2.8-msw-unicode', 'C:\\\\OSGeo4W\\\\apps\\\\qgis-dev\\\\python\\\\plugins\\\\fTools\\\\tools']

#7 Updated by Alexander Bruy almost 8 years ago

  • Category changed from Python plugins to Plugin Manager

#8 Updated by Giovanni Manghi about 7 years ago

  • Regression? set to No
  • Easy fix? set to No

#9 Updated by Paolo Cavallini over 6 years ago

  • Resolution set to fixed/implemented
  • Description updated (diff)
  • Status changed from Open to Closed

Now solved

Also available in: Atom PDF