[Qgis-user] Couldn't load plugin XY due to an error when calling its classFactory() method

Richard Duivenvoorde rdmailings at duif.net
Thu Mar 23 02:07:20 PDT 2023


This means that you do not have a 'locale/userLocale' setting...
Which if the plugin tries to find out your language receiveds 'None'
Which it cannot get the first 2 chars from (using [0:2])

If you open the python console in QGIS, and paste/enter:

QSettings().value('locale/userLocale')
you will probably see nothing or None or Null or so.
With me it shows 'en_US'

To make sure you HAVE such a setting, you could SET it (in python console):
QSettings().setValue('locale/userLocale', 'en_US')
or another preferred language
QSettings().setValue('locale/userLocale', 'nl_NL')
QSettings().setValue('locale/userLocale', 'de_DE')

Then all plugins checking the language in one way or another will at least get the right locale.

It would even be better, if the code in the plugin code would be changed from:
QSettings().value('locale/userLocale')
to
QSettings().value('locale/userLocale', 'en_US')
because THEN if a user does not have a locale/userLocale setting it will return a default en_US value

(@gary: I'm not sure but I think this comes from the plugin builder, is that possible?)

Hope this helps.

Regards,

Richard Duivenvoorde



On 3/23/23 09:23, Bruno Streit via QGIS-User wrote:
> Hi List
> I keep getting an error when loading or installing plugins as 'Geometry Paster', 'Geodata to ENVI-met' and many others. It seems not to be a plugin related error, since it happens with many plugins. Or is it?
> I'm working with QGIS Firenze ltr and had the problem with Biatowieza before. The plugins where updated in this year and are not outdated. In the web I find old error reports but the solutions seem not to fit. It seems to have to do with a 'locale' Setting:
> locale = QSettings().value('locale/userLocale')[0:2]
> TypeError: 'NoneType' object is not subscriptable
> Any hints, how I could solve this?
> Thank you.
> Bruno
> The whole report:
> Couldn't load plugin 'geodata2envimet' due to an error when calling its classFactory() method
> 
> 
>       TypeError: 'NoneType' object is not subscriptable
> 
> Traceback (most recent call last):
>    File "C:\PROGRA~1/QGIS32~1.4/apps/qgis-ltr/./python\qgis\utils.py", line 423, in _startPlugin
>      plugins[packageName] = package.classFactory(iface)
>    File "C:\Users/icuser/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\geodata2envimet\__init__.py", line 36, in classFactory
>      return Geo2ENVImet(iface)
>    File "C:\Users/icuser/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\geodata2envimet\geodata2ENVImet.py", line 2553, in __init__
>      locale = QSettings().value('locale/userLocale')[0:2]
> TypeError: 'NoneType' object is not subscriptable
> 
> 
> Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]
> QGIS version: 3.28.4-Firenze Firenze, fd0fb72ab3
> 
> 
>         Python Path:
> 
>   * C:/PROGRA~1/QGIS32~1.4/apps/qgis-ltr/./python
>   * C:/Users/icuser/AppData/Roaming/QGIS/QGIS3\profiles\default/python
>   * C:/Users/icuser/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
>   * C:/PROGRA~1/QGIS32~1.4/apps/qgis-ltr/./python/plugins
>   * C:\Program Files\QGIS 3.28.4\bin\python39.zip
>   * C:\PROGRA~1\QGIS32~1.4\apps\Python39\DLLs
>   * C:\PROGRA~1\QGIS32~1.4\apps\Python39\lib
>   * C:\Program Files\QGIS 3.28.4\bin
>   * C:\Users\icuser\AppData\Roaming\Python\Python39\site-packages
>   * C:\PROGRA~1\QGIS32~1.4\apps\Python39
>   * C:\PROGRA~1\QGIS32~1.4\apps\Python39\lib\site-packages
>   * C:\PROGRA~1\QGIS32~1.4\apps\Python39\lib\site-packages\win32
>   * C:\PROGRA~1\QGIS32~1.4\apps\Python39\lib\site-packages\win32\lib
>   * C:\PROGRA~1\QGIS32~1.4\apps\Python39\lib\site-packages\Pythonwin
>   * C:/Users/icuser/AppData/Roaming/QGIS/QGIS3\profiles\default/python
>   * C:/data/Solothurn_Mikroklima
> 
> 
> _______________________________________________
> QGIS-User mailing list
> QGIS-User at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user



More information about the QGIS-User mailing list