qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.61k stars 3.01k forks source link

ModuleNotFoundError: No module named 'processing.tools.postgis' #35213

Closed timlinux closed 4 years ago

timlinux commented 4 years ago

Using QGIS macOS nightly build for 3.13

I have a plugin that uses the postgis processing tools.

Launching QGIS I get:

Couldn't load plugin 'gml_application_schema_toolbox' due to an error when calling its classFactory() method 

ModuleNotFoundError: No module named 'processing.tools.postgis' 
Traceback (most recent call last):
  File "/Applications/QGIS3.13.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 334, in _startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "/Users/timlinux/Library/Application Support/QGIS/QGIS3/profiles/Maceira/python/plugins/gml_application_schema_toolbox/__init__.py", line 35, in classFactory
    from .main import MainPlugin
  File "/Applications/QGIS3.13.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 744, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Users/timlinux/Library/Application Support/QGIS/QGIS3/profiles/Maceira/python/plugins/gml_application_schema_toolbox/main.py", line 33, in 
    from .gui.database_widget import DatabaseWidget
  File "/Applications/QGIS3.13.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 744, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Users/timlinux/Library/Application Support/QGIS/QGIS3/profiles/Maceira/python/plugins/gml_application_schema_toolbox/gui/database_widget.py", line 12, in 
    from gml_application_schema_toolbox.core.gmlas_postgis_db import GmlasPostgisDB
  File "/Applications/QGIS3.13.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 744, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Users/timlinux/Library/Application Support/QGIS/QGIS3/profiles/Maceira/python/plugins/gml_application_schema_toolbox/core/gmlas_postgis_db.py", line 3, in 
    from processing.tools.postgis import GeoDB
  File "/Applications/QGIS3.13.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 744, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'processing.tools.postgis'

Python version: 3.7.3 (default, Mar 27 2019, 09:23:15) [Clang 10.0.1 (clang-1001.0.46.3)] 
QGIS version: 3.13.0-Master Master, dd5928c059 

Python Path:
/Applications/QGIS3.13.app/Contents/MacOS/../Resources/python
/Users/timlinux/Library/Application Support/QGIS/QGIS3/profiles/Maceira/python
/Users/timlinux/Library/Application Support/QGIS/QGIS3/profiles/Maceira/python/plugins
/Applications/QGIS3.13.app/Contents/MacOS/../Resources/python/plugins
/Applications/QGIS3.13.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7
/Applications/QGIS3.13.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/lib-dynload
/Users/timlinux/Library/Python/3.7/lib/python/site-packages
/Applications/QGIS3.13.app/Contents/Resources/python
/Applications/QGIS3.13.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python37.zip
/Applications/QGIS3.13.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/site-packages
/Applications/QGIS3.13.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/site-packages/geos
/Users/timlinux/Library/Application Support/QGIS/QGIS3/profiles/Maceira/python
/Users/timlinux/Library/Application Support/QGIS/QGIS3/profiles/Maceira/python/plugins/geosys-plugin
/Users/timlinux/Library/Application Support/QGIS/QGIS3/profiles/Maceira/python/plugins

Screenshot 2020-03-20 at 09 25 07

Opening QGIS 3.12 I don't get the same issue.

The plugin failing is "gml_application_schema_toolbox"

In the toolbox I can't see any difference in the available postgis related algs:

PostGIS processing tools in 3.12: image

PostGIS processing tools in 3.13 nighly:

image

Gustry commented 4 years ago

These functions weren't part of the QGIS stable API and these have been removed indeed this week. I noticed that too, a few plugins are going to be impacted for us. You must report to plugin author.

As a reminder, only these functions are considered stable : https://github.com/qgis/QGIS/blob/master/python/plugins/processing/__init__.py

There is no difference in the Processing toolbox, Processing algorithms are still there.

nyalldawson commented 4 years ago

@gustry is right - this was internal code which had been removed, and 100% will not be resurrected. The plugin will need to copy that file internally and take on maintenance themselves, or (better) do what core processing did and use the native (stable) "connections" API for this functionality.

timlinux commented 4 years ago

Thanks I will report it upstream.

Guts commented 3 years ago

or (better) do what core processing did and use the native (stable) "connections" API for this functionality.

@nyalldawson when you say that, could you provide a link or an example please? That would help me to find out how to make it working on QGIS >= 3.12.

And about these native "connections" API: are they working on QGIS 3.8 and 3.10 or should I handle different cases?

(I'm the actual developer of the mentioned plugin gml_application_schema_toolbox)