QGIS-Contribution / QGIS-ResourceSharing

QGIS Resource Sharing Plugin
http://qgis-contribution.github.io/QGIS-ResourceSharing/
GNU Affero General Public License v3.0
38 stars 18 forks source link

Plugin doesn't work - markupsafe Python package error #243

Closed mapperfr closed 2 years ago

mapperfr commented 2 years ago

Environment

What is the bug?

Can't load the plugin due to a Python error. It appears as installed in the plugin manager but doesn't appear in the menus. Seems to be related to markupsafe Python package?

Python error log:

Impossible de charger l'extension 'qgis_resource_sharing' provoque une erreur lors de l'appel à sa méthode classFactory() 

ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/lib/python3.9/site-packages/markupsafe/__init__.py) 
Traceback (most recent call last):
  File "/app/share/qgis/python/qgis/utils.py", line 423, in _startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "/home/jeremy/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/qgis_resource_sharing/__init__.py", line 55, in classFactory
    from resource_sharing.plugin import Plugin
  File "/app/share/qgis/python/qgis/utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jeremy/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/qgis_resource_sharing/resource_sharing/plugin.py", line 29, in 
    from .gui.resource_sharing_dialog import ResourceSharingDialog
  File "/app/share/qgis/python/qgis/utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jeremy/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/qgis_resource_sharing/resource_sharing/gui/resource_sharing_dialog.py", line 57, in 
    from resource_sharing.gui.manage_dialog import ManageRepositoryDialog
  File "/app/share/qgis/python/qgis/utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jeremy/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/qgis_resource_sharing/resource_sharing/gui/manage_dialog.py", line 31, in 
    from resource_sharing.utilities import ui_path, qgis_version
  File "/app/share/qgis/python/qgis/utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jeremy/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/qgis_resource_sharing/resource_sharing/utilities.py", line 13, in 
    import jinja2
  File "/app/share/qgis/python/qgis/utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/app/lib/python3.9/site-packages/jinja2/__init__.py", line 12, in 
    from .environment import Environment
  File "/app/share/qgis/python/qgis/utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/app/lib/python3.9/site-packages/jinja2/environment.py", line 25, in 
    from .defaults import BLOCK_END_STRING
  File "/app/share/qgis/python/qgis/utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/app/lib/python3.9/site-packages/jinja2/defaults.py", line 3, in 
    from .filters import FILTERS as DEFAULT_FILTERS  # noqa: F401
  File "/app/share/qgis/python/qgis/utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/app/lib/python3.9/site-packages/jinja2/filters.py", line 13, in 
    from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/lib/python3.9/site-packages/markupsafe/__init__.py)

Version de Python : 3.9.9 (main, Nov 10 2011, 15:00:00) [GCC 11.2.0] 
Version de QGIS : 3.24.1-Tisler Tisler, exported 

Chemin Python :
/app/share/qgis/python
/home/jeremy/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python
/home/jeremy/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins
/app/share/qgis/python/plugins
/usr/lib/python39.zip
/usr/lib/python3.9
/usr/lib/python3.9/lib-dynload
/usr/lib/python3.9/site-packages
/app/lib/python3.9/site-packages
/app/lib/python3.9/site-packages/MarkupSafe-2.0.1-py3.9-linux-x86_64.egg
/home/jeremy/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python
/home/jeremy/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/qgis_resource_sharing/ext_libs
Guts commented 2 years ago

Indeed, there is a mismatch with the Markupsafe version (Jinja2 in fact) which has been upgraded between the 3.16 and the 3.22:

3.16

❯ docker run qgis/qgis:release-3_16 python3 -m pip show markupsafe jinja2
Name: MarkupSafe
Version: 2.0.1
Summary: Safely add untrusted strings to HTML/XML markup.
Home-page: https://palletsprojects.com/p/markupsafe/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD-3-Clause
Location: /usr/local/lib/python3.8/dist-packages
Requires: 
Required-by: Jinja2
---
Name: Jinja2
Version: 3.0.3
Summary: A very fast and expressive template engine.
Home-page: https://palletsprojects.com/p/jinja/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD-3-Clause
Location: /usr/local/lib/python3.8/dist-packages
Requires: MarkupSafe
Required-by: Sphinx

3.22

❯ docker run qgis/qgis:release-3_22 python3 -m pip show markupsafe jinja2
Name: MarkupSafe
Version: 2.1.1
Summary: Safely add untrusted strings to HTML/XML markup.
Home-page: https://palletsprojects.com/p/markupsafe/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD-3-Clause
Location: /usr/local/lib/python3.8/dist-packages
Requires: 
Required-by: Jinja2
---
Name: Jinja2
Version: 3.1.1
Summary: A very fast and expressive template engine.
Home-page: https://palletsprojects.com/p/jinja/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD-3-Clause
Location: /usr/local/lib/python3.8/dist-packages
Requires: MarkupSafe
Required-by: Sphinx

3.24

❯ docker run qgis/qgis:release-3_24 python3 -m pip show markupsafe jinja2
Name: MarkupSafe
Version: 2.1.1
Summary: Safely add untrusted strings to HTML/XML markup.
Home-page: https://palletsprojects.com/p/markupsafe/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD-3-Clause
Location: /usr/local/lib/python3.8/dist-packages
Requires: 
Required-by: Jinja2
---
Name: Jinja2
Version: 3.1.1
Summary: A very fast and expressive template engine.
Home-page: https://palletsprojects.com/p/jinja/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD-3-Clause
Location: /usr/local/lib/python3.8/dist-packages
Requires: MarkupSafe
Required-by: Sphinx

To solve it, we'll need to limit the QGIS maximum version in a next release.

Guts commented 2 years ago

@mapperfr try this as a workaround:

python3 -m pip install jinja2==3.1.*
mapperfr commented 2 years ago

Hey @Guts, thanks for checking in! However I just tried to reproduce the bug and everything seems to be working now. I'm running QGIS 3.24.2 revision 3c1a02865 under Ubuntu 22.04 (fresh install. Living on the edge.) Should we close the report?

Guts commented 2 years ago

Thanks @mapperfr for your feedback.

Could you give us what it's returned by python3 -m pip show markupsafe jinja2 on your system?

And good luck on the edge :wink:!

mapperfr commented 2 years ago
$ python3 -m pip show markupsafe jinja2
Name: MarkupSafe
Version: 2.0.1
Summary: Safely add untrusted strings to HTML/XML markup.
Home-page: https://palletsprojects.com/p/markupsafe/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD-3-Clause
Location: /usr/lib/python3/dist-packages
Requires: 
Required-by: 
---
Name: Jinja2
Version: 3.0.3
Summary: A very fast and expressive template engine.
Home-page: https://palletsprojects.com/p/jinja/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD-3-Clause
Location: /usr/lib/python3/dist-packages
Requires: 
Required-by: 

That's odd.

Guts commented 2 years ago

A new version is available with a bunch of improvments and fixes:

For now, it's still flagged as experimental.
Can you test again and tell me if you still encounter this bug please?

Guts commented 2 years ago

@mapperfr can we close here?

mapperfr commented 2 years ago

I missed your previous message, sorry about that! Just tried 1.0.0-beta1, everything seems to be working fine. Closing the ticket, thanks for the support @Guts.